#60378 - 2001-11-07 04:27 PM
Forced Logoff or shutdown for Win9x
|
Jeroen
Starting to like KiXtart
Registered: 2001-08-16
Posts: 180
Loc: Netherlands
|
Hi all,I can't seem to get a forced logoff or shutdown for Win9x. Logoff(1) doesn't work: the computers hang up with the screen 'Please wait while your logon script executes'. (while Break=on). Also, calling Rundll32 krnl386.exe,exitkernel doesn't work; same problem as with Logoff(1). Also tried Rundll32 shell32,SHExitWindowsEx 0, -> doesn't work. Rundll32 user,exitwindows isn't the solution either. Any ideas?
_________________________
Regards, Jeroen.
There are two ways to write error-free programs. Only the third one works.
|
Top
|
|
|
|
#60379 - 2001-11-07 04:31 PM
Re: Forced Logoff or shutdown for Win9x
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
|
Top
|
|
|
|
#60380 - 2001-11-07 05:15 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
These work like a champ:Logoff: rundll.exe shell32.dll,SHExitWindowsEx 4 Reboot: rundll.exe shell32.dll,SHExitWindowsEx 6 Important notes, though: 1) These are 100% case-sensitive! You must type them exactly as I typed them above. 2) Windows 9x will not let the system shut down cleanly, because KiX is still running. So the way to work around this is to execute the above command line via the HKLM\...\RunOnce registry key. This will initiate the shutdown process, after the script finishes, but before the user can really start to do anything... To keep it clean, throw out a message box during the script that says something like "changes made... you computer will be restarted...". Then write the value, and finally, issue a QUIT command. Here is a complete example: code:
$rc=messagebox('computer will restart','notice',4112,10) $rc=writevalue('HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce','9xReboot','rundll.exe shell32.dll,SHExitWindowsEx 6','REG_SZ') Quit 0
Hope this helps you -- those few lines were about 20 hours of work to get perfect...
|
Top
|
|
|
|
#60382 - 2001-11-07 11:15 PM
Re: Forced Logoff or shutdown for Win9x
|
Jeroen
Starting to like KiXtart
Registered: 2001-08-16
Posts: 180
Loc: Netherlands
|
Thanks so far people, but.. There is one problem though; The script calling this function was designed to prevent logging on to the network by non company PC's like PC's from contractors or private laptops from employees. Since policies are not applied untill after the logon script, it is possible that the shell/explorer has already started before the RunOnce key was written, which means the RunOnce will execute the next time people use the PC instead of immediately..If for example people log on to their PC while the network cable is out of the laptop, they are logged on locally. If they put the network cable in while working locally, they automatically log on and the logon script executes (if the credentials are kept the same). Same problem with RunOnce in that case. Now I've tried a couple of shutdown, reboot, and logoff tools, and also the functions that Rundll provides, but none of them seem to be able to kill the logon script and logoff or reboot thus preventing logging on to the domain. Any ideas? The closest I came to a solution was either using a delay program which calls Rundll after x seconds, or shutting down the kernel using a kernel386 command. The delay function isn't all that because the logon script has different forms depending on account and group membership, and the speed of the PC also plays a part in determining the number of seconds. Shuting down the kernel works OK on '98 (nice shutdown), but on '95 the computer hangs... I'm almost out of options?... I'll give shutdown.exe a g tomorrow, as well as the '4' and '6' parameters of the Rundll command's. I've only tried '0'... I'll let you know what happens... [ 07 November 2001: Message edited by: Jeroen ]
_________________________
Regards, Jeroen.
There are two ways to write error-free programs. Only the third one works.
|
Top
|
|
|
|
#60386 - 2001-11-08 10:29 AM
Re: Forced Logoff or shutdown for Win9x
|
Jeroen
Starting to like KiXtart
Registered: 2001-08-16
Posts: 180
Loc: Netherlands
|
Les, Thanks for the input. I tried break on in the script, then terminated it using the End Task function. This however didn't force a logoff either. (Stupid Win9x)...Bstyles' rundll.exe shell32.dll,SHExitWindowsEx 6 seems to do the trick however, on both Win98 and Win95. It reboots the computer. I'll have to do some testing on a couple of additional PC's, but I think this may be it; Thanks! Should I still encounter a problem, I will use the errorlevel method. I do have a question about that though: How do I handle exit codes if the script that generates the exit code was called by another script? Like: code:
If $Logoff=1 Exit(4) Else Exit Endif
Then returning to the 'mother-script' which should also exit if the exitcode is 4, and also should leave the exitcode intact for the batch file to process the Rundll command..? Would that be something like: code:
Call "Authorised.kix" ; after the script returns, check for exitcode If %1%="4" Exit(4) Endif
_________________________
Regards, Jeroen.
There are two ways to write error-free programs. Only the third one works.
|
Top
|
|
|
|
#60387 - 2001-11-08 04:51 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
Yes, 6 = Reboot, 4 = Logoff. There are two values you can use, depending on your situation. Please review my earlier post. Sounds like you're close.  -Brian
|
Top
|
|
|
|
#60389 - 2001-11-08 09:09 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
Rather than I post a new thread, I prefer to post my similar problem here.I use shutdown.exe (from Bryce posting) to reboot the Win95 PCs after updating McAfee dat files. It used to work well, but lately I received many complaints reporting that PCs were freezed/stuck on the screen of "Windows is shutting down". We are using Compaq and Dell PCs. The reboot worked for some Compaq EX (desktop type), but freezed on Dell and Compaq EN (slim type). It only happened to Win95 clients and we are using Kix v3.63. The specific lines I used as follows: RUN "%WINDIR%\SHUTDOWN.EXE /REBOOT /FORCE /NOLOGO /NOCANCEL" SLEEP 3 COOKIE1 EXIT Appreciate any help. Thanks.
|
Top
|
|
|
|
#60391 - 2001-11-08 10:16 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
Thanks, Les.I'll try your suggestion and will post the result. Benny Somali
|
Top
|
|
|
|
#60392 - 2001-11-09 08:28 AM
Re: Forced Logoff or shutdown for Win9x
|
Jeroen
Starting to like KiXtart
Registered: 2001-08-16
Posts: 180
Loc: Netherlands
|
Les, I've tried a loop of death with break off, but when users kill the task they somehow aren't logged off by Kix. Also, if I do this, there may be users who don't know what to do or how to kill a task, and then they would have to call the helpdesk for support, and I'd like to avoid that too...Brian, the 4 didn't do the trick; at least not on Win95. (did work on Win98), but 6 works on both so far. I still have to test a couple of extra PC's before making the script 'live' but I think this is it! Thanks!
_________________________
Regards, Jeroen.
There are two ways to write error-free programs. Only the third one works.
|
Top
|
|
|
|
#60394 - 2001-11-09 05:07 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
Hi Les.Adding line Break On didn't help (in fact, there was already Break On at the start of script). It seemed it works well on faster PCs and W2K clients. After updating new dat, reboot was required for Windows to update its registry and reload new dat. Is there execution timing issue? The reason why I add Sleep 3 was to get shutdown.exe to execute. If I removed Sleep 3, the scripts end normal without executing shutdown or likely terminated. I used sdat*.exe with "force and silent" option. I haven't tried to add "reboot" option. I prefer to control the reboot requirement at the end of script. I am going to try bstyles suggestion too. Appreciate further inputs.
|
Top
|
|
|
|
#60396 - 2001-11-09 09:43 PM
Re: Forced Logoff or shutdown for Win9x
|
Anonymous
Anonymous
Unregistered
|
I have tried using Shell before. It always stopped to ask to close the script windows. I prefer to run shutdown.exe from batch file and it works fine. Yet I need to see how it performs on all PCs on next DAT update.However, shutdown.exe works well with only /reboot /nocancel options. If I add /force /nologo options, the same problems occured. Btw, I got error of missing entry SHExitWindowsEx when I used rundll.exe shell32.dll,SHExitWindowsEx 6. I guess this works only with W98. Thanks and regards, Benny
|
Top
|
|
|
|
#60397 - 2001-11-10 01:09 AM
Re: Forced Logoff or shutdown for Win9x
|
splattman
Lurker
Registered: 2001-11-10
Posts: 2
|
I didn't read all the posts here, so not sure if you have considered this: Windows 98 has a serious shutdown bug and MS has a long-ass document on how to troubleshoot, which in 9 times out of 10 (or more), it doesn't work. The solution? Upgrade to Windows NT or 2000. Sounds like a smart-ass way, but you'll find that I'm right. I spent hours and hours researching this a couple of years ago, and you'll NEVER find a fix. Just thought I'd save you hair. I am now bald. Later. Good luck. Don't waste any more time. If users complain, just tell them to hold the power button in a few seconds, it will shut down. Sorry, just the facts.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|