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...