2

Every single guide on the net says to use RUNDLL USER.EXE,ExitWindows which works... from the run command

However, when run from a bat file, this command, although it works, requests confirmation to kill the 'remaining' processes. That process is the cmd line itself. I haven't been able to call it with 'CALL' but since call creates a new command line i expect the result to be the same.

This is a windows 95 question only, it's for a virtual machine to auto shutdown after running a application. The idea is basically to have a script on the Startup programs folder that starts the app, waits until it exits with START /WAIT, then uses something to auto shutdown windows.

user
  • 30,336
SCO
  • 21

4 Answers4

2

If you set your program as the shell instead of explorer then it will autorun and windows will shutdown when the program exits.

From a post I made in 2001

Copy it to c:\windows. If you edit c:\windows\system.ini and change

shell=explorer.exe 

to

shell=progman.exe

then your computer will start in win3.11 interface mode.


From my 15 year since last updated web site http://www.mvps.org/serenitymacros

Exiting Windows

The first three sections are from Tweak95 available on the downloads page. The fourth section is changes with Win98.

Shut Down Windows

A command to exit Windows 95. This can only be used to shutdown, not restart or exit to msdos. To exit to msdos type ExitToMsDos which runs the Pif file of the same name. Place command in a shortcut or batch file.

C:\WINDOWS\RUNDLL32.EXE user.exe,ExitWindows

Restart Windows

To restart Windows copy Exit To Dos.pif (the pif part is hidden) and copy and rename it to Restart Windows. Edit the Program Sheet in the properties Change the command line to:

C:\WINDOWS\command.com /C exit

Make sure Close On Exit is checked. On the Advanced dialog check Use Current MSDos Configuration to exit and restart Windows without rebooting. Check Warn Before Entering MSDos Mode if confirmation is required before exiting and restarting. MSDos Mode must be checked.

An alternative way is to use the ExitWindowsExec function. This exits to MSDos to run a program, but as no program is given Windows restarts. Tpye into a shortcut or Start - Run dialog box.

C:\WINDOWS\RUNDLL.EXE user.exe,ExitWindowsExec

Shut Down Dialog Box

This reg file will set the default choice in the Shut Down dialog box. Windows 95B and IE4 remember the last setting chosen, so to set the default for these versions (rather than the last action) add the following command line to C:\Windows\Winstart.bat (create Winstart.bat if necessary). Remember to use the short filke name.

Regedit C:\<Path to Reg File>\ShutDown.Reg

Or this command line to a shortcut and put it in the StartUp folder.

Regedit /s C:\<Path to Reg File>\ShutDown.Reg

REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
'1=first choice in dialog box, 2=second choice, ect.
"Shutdown Setting"=dword:00000001

Via the SHExitWindowsEx

Using the User.exe & User32.dll Exit Windows functions doesn't allow any control over what type of shutdown is preformed as parameters aren't passed, they operate as if 0 is passed - which is shutdown for ExitWindows and Logoff for ExitWindowsEx. An undocumented function SHExitWindowsEx in Shell32.dll which is what Explorer seems to use does take parameters.

rundll32.exe shell32.dll,SHExitWindowsEx [optional number in hex]

Action Value in Hex

EWX_LOGOFF 0 
EWX_SHUTDOWN 1 
EWX_REBOOT 2 
EWX_FORCE 4 
EWX_POWEROFF
for machines that turn off their own power 8 

These values can be added together, eg, 5 is shutdown and force applications to close and an implicit logoff.

Note their is no Restart without rebooting. This requires a parameter of 42 (hex) to be passed to ExitWindows in User.exe. This can't be done from the command line. See tip above for a work around.

bill
  • 31
1
%windir%\System32\shutdown.exe -r -f

Adding -f forces system to shutdown or reboot. in windows 95, the path would be C:\Windows\Command referring to this website

Botmaster
  • 186
0

Try calling the above command with start should let you run it in the background, and not leave a cmd.exe waiting around. I don't know the 9x syntax off the top of my head but do a start /? at the command line.

Zoredache
  • 20,438
0

There are several automated shutdown methods for contemporary computers (see this link and this) but Windows 95 is so old that I they may not work. (Still, try your luck.) If all failed, I am afraid you only option would be to create one yourself; i.e. create a Windows 95 app that shuts down the computer.