>//******************************************************************************************* >// Initialise variables >// First is the required URL & timeout for page to load >// Next is the form name & the user/password input fields >// Next is the actual user name & password >//~****************************************************************************************** >url="http://www.levelextreme.com" >tmo = 60 * 1000 > >frm="Login" >unf="Username" >pwf="Password" > >un = "myname" >pw = "mypassword" > >var wsh = WScript.CreateObject( "WScript.Shell" ) >wsh.Run( "autolog.js " + url + " " + tmo + " "+ frm + " "+ unf + " "+ pwf + " "+ un + " "+ pw, 1, 0 ) >>
>//~****************************************************************************************** >// Create Script Shell for error reporting >//~****************************************************************************************** >var wsh = WScript.CreateObject( "WScript.Shell" ) > >//******************************************************************************************* >// Check parameters >// 1st is the required URL >// 2nd is timeout for page to load >// 3rd is the form name >// 4th is the user input field name >// 5th is password input field name >// 6th is the actual user name >// 7th is the actual password >//~****************************************************************************************** >var argo = WScript.Arguments >if ( argo.Length != 7 ) > { > wsh.popup( "Invalid Number Of Parameters" ) > Quit > } > >url = argo(0) >tmo = argo(1) > >frm=argo(2) >unf=argo(3) >pwf=argo(4) > >un = argo(5) >pw = argo(6) > >//~****************************************************************************************** >// Create IE object, default is invisible, so make visible >//~****************************************************************************************** >var oc = new ActiveXObject( "internetexplorer.application" ) ; >oc.visible = 1 > >//~****************************************************************************************** >// Navigate to required page >// Check for page fully loaded - occassionally busy is set to False before page is >// fully loaded, ReadyState is more reliable (probably could check only that) >// Timeout check while loading >//~****************************************************************************************** >oc.navigate( url ) >dtes = new Date().valueOf() >tmeout = false >while ( oc.busy || (oc.ReadyState != 4) ) > { > dten = new Date().valueOf() > if ( (dten - dtes) > tmo ) > { > tmeout = true > break > } > } >if ( tmeout ) > { > wsh.popup( "Timed Out" ) > Quit > } > >//~****************************************************************************************** >// Fill in fields & submit if possible >// Error if cannot find the form >//~****************************************************************************************** >tstpg = frm in oc.Document >if ( tstpg ) > { // create basic string for form on document > frms = "oc.Document." + frm + "." > // put user name into to user input field > eval( frms+unf + ".value = un" ) > // put password into to password input field > eval( frms+pwf + ".value = pw" ) > // submit form > eval( frms+"submit()" ) > } >else > wsh.popup( "No Logon Form" ) >