trids Posted December 11, 2003 Share Posted December 11, 2003 I'm using AI3 to autopilot a setup process, which needs a reboot halfway through. Any ideas on how to accomplish this with one script on NTWS4? In the interests of minimal human intervention, I'd like to avoid the obvious of having the user fire two scripts: the first one steering the process through until the reboot; the next one he starts after the reboot has completed and he has logged in again (with Administrator authority). If there isn't any simple way to achieve this, then two scripts it will have to be. TIA Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2003 Developers Share Posted December 11, 2003 Below a porton of a script I use to install software in steps with reboots in between... more or less like Larry described.. jos ; pgm name DEMO.AU3 $Userid="Administrator" $Psw="adminpsw" ; Remove autologin params from registry to clean up SetAutoLogon("Off", "") ; ; retrieve param $param1 = "" If $CmdLine[0] > 0 then $param1 = $CmdLine[1] endif ; Act on it Select Case $param1 = "" ; run your programs with admin account if needed in the first step RunAsSet($userid, @Computername, $psw) ; ; *** put your stuff here for step1 *** RunWait("notepad.exe step1.txt") ; SetAutoLogon("On", "step1") Shutdown(6) Case $param1 = "step1" ; is already logged on with admin account ; ; *** put your stuff here for step2 *** RunWait("notepad.exe step2.txt") ; SetAutoLogon("On", "step2") Shutdown(6) Case $param1 = "step2" ; logoff the admin account ; *** put your stuff here for step3 *** RunWait("notepad.exe step3.txt") ; just logoff Shutdown(0) Exit EndSelect exit ; ; Func SetAutoLogon($sw,$step) If $sw = "On" Then ; set the registry to start this program again after reboot RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo", "REG_SZ", @ScriptFullPath & " " & $step) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","AutoAdminLogon","REG_SZ","1") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultDomainName", "REG_SZ",EnvGet("LOGONSERVER")) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultUserName", "REG_SZ",$Userid) RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultPassword", "REG_SZ",$Psw) EndIf ; If $sw = "Off" Then ; Remove the registrykey to start this program again after reboot RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN", "Demo") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","AutoAdminLogon","REG_SZ"," ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultDomainName", "REG_SZ"," ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultUserName", "REG_SZ"," ") RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","DefaultPassword", "REG_SZ"," ") EndIf EndFunc SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
trids Posted December 12, 2003 Author Share Posted December 12, 2003 That's excellent - just what I'm after .. thanks guys! Link to comment Share on other sites More sharing options...
trids Posted December 15, 2003 Author Share Posted December 15, 2003 Thanks again to Larry and JdeB for showing me how to get the reboot to work! But now .. I'm struggling a bit trying to get pass-2 of the script to fire after successfully rebooting. The setup that I'm auto-piloting hijacks the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUN for it's own purposes, and I can't seem to get it to also launch pass-2 of my script .. so I was thinking I might use Larry's alternative of putting a shortcut in the startup folder instead.I guess I would use the FileCreateShortcut function: but should I put the commandline parameter to the script in the "file" specification along with the au3 reference (option-1 below)? Or in the "args" specification (option-2 below)?;Option-1 FileCreateShortcut (@ScriptFullPath & " pass2", @StartupDir & "\autopilot.lnk") ;Option-2 FileCreateShortcut (@ScriptFullPath, @StartupDir & "\autopilot.lnk", "", "pass2", "", "", "").. Or is there another tree I should be barking up?- TIA Link to comment Share on other sites More sharing options...
trids Posted December 15, 2003 Author Share Posted December 15, 2003 OK gottit - ;o) .. option-2 is the only one that produces usable results so far. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 15, 2003 Developers Share Posted December 15, 2003 trids, what seems to be the issue running your script after reboot ? maybe you can post or sent me your script then I'll have a look.. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
nobby Posted December 16, 2003 Share Posted December 16, 2003 There also is a registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RUNONCE where you can write the 2nd script details. It will run once and delete the relevant data from the registry. Another idea if you are running on a network is to assign a login script to the relevant user and run the second script from there. Cheers CheersNobby Link to comment Share on other sites More sharing options...
trids Posted December 17, 2003 Author Share Posted December 17, 2003 In the end, I'm creating a shortcut in @StartupDir as Larry suggested, and deleting it in the second pass. Works very nicely indeed. Thanks for all the ideas folks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now