Page 1 of 1 1
Topic Options
#1124 - 1999-12-07 01:37 PM Wierd RunOnce adventure
Anonymous
Unregistered


Hi everyone,

I've written a deployment script for SP5 which basicly does this:
- create autoadmin logon and reboot, schedule next part (kix script) through Runonce
- logon using domain account with local Adminrights, download sp5 and execute (autoreboot) schedule next part (kix script) through Runonce
- Reset autoadmin logon and reboot.

This works fine if I don't use the Runonce (execute each script manually), however when I use Runonce part 3 gets executed right after part 2. I've tried forcing the explorer shell to start up but that doesn't help. I'm using Kix v4.62 on WinNT, all scripts and kix executeable are in the Netlogon.

Please help!!!??? I'll be happy to provide more info if needed...

Thanks in advance,

David

Top
#1125 - 1999-12-07 01:47 PM Re: Wierd RunOnce adventure
Anonymous
Unregistered


David

Post the script so that others may spot likely problems or errors. Not saying there are any but another pair of eyes may spot something you miss?

Rgds

------------------
Don Davidson
Network Engineer
http://www.insight-media.co.uk


Top
#1126 - 1999-12-07 01:58 PM Re: Wierd RunOnce adventure
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I don't have the info with me at the moment but I believe the sequence of execution is "runonce" executes right after login. I think you want to reboot & then execute the runonce. I think what this means your runonce must re-poke another batch job into runonce.
_________________________
Jack

Top
#1127 - 1999-12-08 03:09 AM Re: Wierd RunOnce adventure
Anonymous
Unregistered


Script(s):

Part1 (executes from login script(in this case test environment):
goto "MAIN"

:MAIN
$CaptureError=SETCONSOLE("HIDE")
$CaptureError=SETCONSOLE("MINIMIZE")
$CaptureError=SETCONSOLE("ALWAYSONTOP")

; ******** Do NOT include the section below in the production script *********
$Selection = MESSAGEBOX ("Please note that the login script currently executing is the test environment. The script executed is TEST.KIX. Do you wish to continue?", "TEST Warning", 292)
If $Selection = 6
? "Yes selected, executing script...."
Endif
If $Selection = 7
? "No selected, script will not be executed...."
goto "END"
Endif
; ******** Do NOT include the section above in the production script *********

goto "ITEM4"

; ****************************************************************************
; Start Service Pack 5 deployment (ITEM4)
; ****************************************************************************

:ITEM4
$SPLEVEL = ReadValue( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion" , "CSDVersion" )
;IF $SPLEVEL = "Service Pack 5"
IF $SPLEVEL = "Service Pack 6"
OR $SPLEVEL = "Service Pack 6a"
OR $SPLEVEL = "Service Pack 7"
GOTO "ENDSP5"
ENDIF
? @SERROR
GOTO "DISKSPACE"

ISKSPACE
$DISKSPACE = GETDISKSPACE ( "C:\" )
IF $DISKSPACE < 300000 GOTO "SHORTSPACE"
ENDIF
GOTO "SP5NOTIFY"

:SHORTSPACE
Messagebox ("Please note that your system is running low on diskspace. For " + CHR(10) + "optimum performance it is required that you have at least" + CHR(10) + "350Mb of free diskspace." + CHR(10) + CHR(10) + "Please feel free to contact the Helpdesk at " + CHR(10) + "extension: xxxx if you need any assistance.", "Short on diskspace", 48)
GOTO "ENDSP5"

:SP5NOTIFY
Messagebox ("Please note that the Windows NT Service Pack on this system will be" + CHR(10) + "upgraded to Windows NT Service Pack 5 in order to meet Year 2000" + CHR(10) + "compliancy." + CHR(10) + "Please do NOT use this computer untill it is completly finished, " + CHR(10) + "otherwise your system may get irrepairable damaged. This computer" + CHR(10) + "will be automatically rebooted during this process." + CHR(10) + CHR(10) + "This computer will be ready for usage again when the logon screen is " + CHR(10) + "visible again for at least 5 minutes." + CHR(10) + CHR(10) + "Thank you kindly for your patience.", "Service Pack 5 installation notification", 48)
GOTO "AUTOLOGON"

:AUTOLOGON
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption" )
? @SERROR
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DontDisplayLastUserName", "0", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "DefaultNetWareUserName", "localadminaccount", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "DefaultNetWarePassword", "password", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "NetWareAutoAdminLogon", "1", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "DOMAIN-NT1", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "localadminaccount", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "password", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "1", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "SP5Install", "\\SERVER01\Netlogon\Kix32 \\SERVER01\Netlogon\SP5.kix", "REG_SZ" )
? @SERROR
GOTO "SP5START"

:SP5START
SLEEP 5
SHELL "%COMSPEC% /e:1024 /c copy \\SERVER01\netlogon\reboot.kix c:\temp"
? @SERROR
SLEEP 5
RUN "\\SERVER01\Netlogon\kix32 c:\temp\reboot.kix"
? @SERROR
GOTO "ENDSP5"

:ENDSP5
GOTO "ITEM5"

; ****************************************************************************
; End Service Pack 5 deployment (ITEM4)
; ****************************************************************************

---> Script Part 2 (SP5.kix)
GOTO "MAIN"

:MAIN
$CaptureError=SETCONSOLE("HIDE")
$CaptureError=SETCONSOLE("MINIMIZE")
$CaptureError=SETCONSOLE("ALWAYSONTOP")
GOTO "CONNECT"

:CONNECT
USE X: "\\SERVER06\SP5$"
? @SERROR
Sleep 5
GOTO "PREPARE"

:PREPARE
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "999.PostSP5Install", "\\SERVER01\Netlogon\Kix32 \\SERVER01\Netlogon\PostSP5.kix", "REG_SZ" )
? @SERROR
GOTO "UNPACK"

:UNPACK
;SHELL "X:\SP5I386.EXE /X:c:\winnt\options\sp5 -u -o"
Sleep 30
GOTO "DEPLOY"

EPLOY
;RUN "C:\Winnt\options\SP5\update\update.exe -f -n -u -o"
GOTO "END"

:END
exit


-----> Script Part 3 (PostSP5.kix)
GOTO "MAIN"

:MAIN
$CaptureError=SETCONSOLE("HIDE")
$CaptureError=SETCONSOLE("MINIMIZE")
$CaptureError=SETCONSOLE("ALWAYSONTOP")
GOTO "CLEANREG"

:CLEANREG
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "Legal Counsel Notice", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText", "Bla bla you are under arrest!", "REG_SZ" )
? @SERROR
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword" )
? @SERROR
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon" )
? @SERROR
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "DefaultNetWarePassword" )
? @SERROR
DELVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "NetWareAutoAdminLogon" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Novell\NWGINA\Login Screen", "DefaultNetWareUserName", "", "REG_SZ" )
? @SERROR
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DontDisplayLastUserName", "1", "REG_SZ" )
? @SERROR
GOTO "CLEANLOCAL"

:CLEANLOCAL
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "SP5Install", "CMD /C del c:\temp\reboot.kix /q", "REG_SZ" )
? @SERROR
GOTO "SP5SUCCES"

:SP5SUCCES
WRITEVALUE ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "998.SP5Finished", "Notepad.exe \\SERVER01\Netlogon\SP5Installed.txt", "REG_SZ" )
? @SERROR
GOTO "SP5FINISH"

:SP5FINISH
SLEEP 90
RUN "\\SERVER01\Netlogon\kix32 c:\temp\reboot.kix"
GOTO "END"

:END
exit


-----> Reboot script
Sleep 5
SHUTDOWN ("", "Your system is being rebooted to start Service Pack 5 installation procedure", 0, 1, 1)

Top
#1128 - 1999-12-08 03:18 AM Re: Wierd RunOnce adventure
Anonymous
Unregistered


Please Note that ITEM4 should read:

:ITEM4
$SPLEVEL = ReadValue( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion" , "CSDVersion" )
IF $SPLEVEL = "Service Pack 5"
OR $SPLEVEL = "Service Pack 6"
OR $SPLEVEL = "Service Pack 6a"
OR $SPLEVEL = "Service Pack 7"
GOTO "ENDSP5"
ENDIF
? @SERROR
GOTO "DISKSPACE"

Please Note that UNPACK should read:

:UNPACK
SHELL "X:\SP5I386.EXE /X:c:\winnt\options\sp5 -u -o"
Sleep 30
GOTO "DEPLOY"

Please Note that DEPLOY should read:

EPLOY
RUN "C:\Winnt\options\SP5\update\update.exe -f -n -u -o"
GOTO "END"


I commented this to test the procedure.

Any comments or questions are welcome

Top
#1129 - 1999-12-08 04:34 AM Re: Wierd RunOnce adventure
Anonymous
Unregistered


Jack, Don,

I think this is what I've done, I'll try to explain it more specific: the shell doesn't start up after the kix script is executed (especially the scripts started of the RunOnce), no matter what (sleep 1000) the shell is put on hold somehow untill the kixscript is executed. This is what happens (and what I do):

- Login script executes, places next script in RunOnce and reboots system (this works fine).
- SP5.kix runs, places next script (postsp5.kix) in RunOnce but puts the shell on hold. Thus when SP5 script is finished the shell starts up and RunOnce entries are executed and thus the postsp5 is executed before the system is actually rebooted by the SP5 and SP5 RunOnce entries also get executed before the system is rebooted (which should take place after the system reboots).

Putting another script in between SP5.kix and PostSP5.kix would solve the issue for say the user message but still wouldn't let the SP deploy in the way it was designed to be executed (run sp5, reboot, finish sp5). Obviously I don't want to take the risk to spread a half installed SP and run into all kinds of related problems.

Hopes this clarifies the issue somewhat more.

David

Top
#1130 - 1999-12-09 07:47 AM Re: Wierd RunOnce adventure
Anonymous
Unregistered


Hi I solved the issue starting all other kix scripts with a .bat file.
After analysing this I'd say RunOnce entries are either always executed before the shell starts up or .kix extension are always seen as part of a login script (since we've got 'Run login scripts synchronously' activated).
Starting these scripts with a .bat or .cmd file tricks the OS into thinking all scripts have been executed and is allowed to start up the shell.

David

Top
#1131 - 1999-12-09 01:14 PM Re: Wierd RunOnce adventure
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Thanks for the followup note. I have never tried calling a kix script directly in the runonce key. Interesting, but I must admit it seems inexplicable. I thought I understood runonce but I guess I don't.
_________________________
Jack

Top
#1132 - 1999-12-10 05:36 AM Re: Wierd RunOnce adventure
Anonymous
Unregistered


David, Jack

So far any RunOnce programs I have thrown at Win9x thru Kixtart have been .bat, .exe or .cmd files.

I too had never tried starting a kix script directly from runonce.

An interesting bit of info though is,
MS says on the "Definition of the RunOnce keys in the Registry", "For keys3-4, the command line can be prefixed with an exclamation point to defer deletion of the value until after the command has been completed." "For keys 3, 4 and 6, the value is deleted before the command line is run unless overridden as noted above. As a result, if a RunOnce operation fails to run properly, the component that failed will not be asked to run again the next time you start the computer.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce is key 3.

Does this help explain anything?
It's certainly useful to know.

Rgds

------------------
Don Davidson
Network Engineer
http://www.insight-media.co.uk


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.053 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org