Page 1 of 2 12>
Topic Options
#60378 - 2001-11-07 04:27 PM Forced Logoff or shutdown for Win9x
Jeroen Offline
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 Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
give this a shot
http://kix.isorg.net/kix_tools/SHUTDOWN.EXE

Top
#60380 - 2001-11-07 05:15 PM Re: Forced Logoff or shutdown for Win9x
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
#60381 - 2001-11-07 08:10 PM Re: Forced Logoff or shutdown for Win9x
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11625
Loc: CA
Thanks bstyles,

Have not verified the code, but sounds like sound code. Good job.

Top
#60382 - 2001-11-07 11:15 PM Re: Forced Logoff or shutdown for Win9x
Jeroen Offline
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
#60383 - 2001-11-08 02:22 AM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jeroen,
Have you thought of throwing the user into a loop of death that only an end task will get them out of? I think KiX would log them off in that case provided break=off is set.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60384 - 2001-11-08 02:27 AM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
One other thought... if you call KiX from logon.bat, you could test for an exit code from KiX in the line that follows the call to KiX. Then use Exit(code) to pass an errorlevel to the next line.

No network or Wintendo at home to test.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60385 - 2001-11-08 07:16 AM Re: Forced Logoff or shutdown for Win9x
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

To prevent a kix32 problem you can run them also from a batch file.
How?

code:

@echo off
kix32 %0\..\your_script.kix
if errorlevel 6 rundll.exe shell32.dll,SHExitWindowsEx 6
if errorlevel 6 goto end
if errorlevel 4 rundll.exe shell32.dll,SHExitWindowsEx 4
if errorlevel 4 goto end
:end
@echo off


Your are leaving your kixtart script with f.e Exit(4) for a logoff and
Exit(6) for a reboot.
Very important that the errorlevel order is reversed. Order 4+6 with exit code 6
results in the execution of errorlevel setting 4 and later on - when it is pos-
sible - setting 6. The order 6+4 with same error code will execute only set-
ting 6.
Also you must prevent users can work during the processing of your
logon script. Sometimes a policy setting runs your script asynchronous.

Brian, we see many times topics about same issue and the doesn't always
contain the complete answer. Your story gives a good overview about
"how to do it" and your code is very easy. Good job.

greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#60386 - 2001-11-08 10:29 AM Re: Forced Logoff or shutdown for Win9x
Jeroen Offline
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
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
#60388 - 2001-11-08 04:52 PM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
MCA,
Thanks for putting my half-baked idea in the oven.

Jeroen,
My first of two suggestions, re: loop of death, could only work if break=off.

It would appear the RunDLL solution is highly dependent on which flavor of Wintendo you're running. In my shop, they are all cloned from one parent, so not an issue. Also not able to test variations.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60389 - 2001-11-08 09:09 PM Re: Forced Logoff or shutdown for Win9x
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
#60390 - 2001-11-08 09:31 PM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
bsomali,
As you are probably aware, if you read this and other threads, shutting down Wintendo is not without problems. In your case I'm not sure why you do a sleep before exit. Have you tried putting break=on just before you run shutdown? I have seen some cases where that helps.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60391 - 2001-11-08 10:16 PM Re: Forced Logoff or shutdown for Win9x
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 Offline
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
#60393 - 2001-11-09 04:20 PM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jeroen,
That loop of death thing was just a brain fart any way... don't sweat it. When you get something that works across different Wintendo flavors, please share it with us.

Check out this link for more on this topic.
http://www.robvanderwoude.com/shutdown.html

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60394 - 2001-11-09 05:07 PM Re: Forced Logoff or shutdown for Win9x
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
#60395 - 2001-11-09 06:09 PM Re: Forced Logoff or shutdown for Win9x
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Benny,
The thinking on the Break=on is that in some cases, KiX may have a kill-resist. So, you're trying to hold KiX with Sleep... not reliable with different processor speeds... Maybe could consider Shell instead of Run. Also, maybe try to run shutdown from logon.bat using exit code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60396 - 2001-11-09 09:43 PM Re: Forced Logoff or shutdown for Win9x
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 Offline
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
Page 1 of 2 12>


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

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.084 seconds in which 0.041 seconds were spent on a total of 13 queries. Zlib compression enabled.

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