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.

4 Answers 4

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.

1
  • Are you sure you tested this on Windows 95? SHExitWindowsEx only seems to work on 98 (and probably ME and 2000).
    – Anders
    Commented May 18, 2023 at 22:53
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

2
  • I'm pretty sure that Windows 95 did not have the system32 directory, let alone shutdown.exe...
    – user
    Commented Aug 10, 2015 at 8:52
  • are you sure? youtube.com/watch?v=QtUaOHPi3II
    – Botmaster
    Commented Aug 10, 2015 at 9:05
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.

1
  • I know, but i tried that. Start RUNDLL USER.EXE,ExitWindows followed by EXIT (it's one of those pesky permanent windows) seems to do... nothing. I also tried variations based on the syntax examples i found: Start "" "RUNDLL USER.EXE,ExitWindows", Start "" RUNDLL USER.EXE,ExitWindows etc.
    – SCO
    Commented Aug 6, 2015 at 5:20
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.

4
  • Just a note that Win95 depends on cooperative multitasking, and there may be occasions when it cannot shut down while a process is executing. Commented Aug 6, 2015 at 4:23
  • @drmoishe-pippik: Windows 95 uses cooperative multitasking only for 16-bit processes. In addition, the shutdown blocking issue only applies to processes that do not respond to the WM_QUERYENDSESSION and WM_ENDSESSION messages in a timely fashion.
    – user477799
    Commented Aug 6, 2015 at 6:32
  • Umm... Windows 95 did not have preemptive multitasking... NT was the first MS system that did. Commented Aug 7, 2015 at 4:27
  • @DrMoishe Pippik: NT was the first Microsoft OS that did it, yes. And it came before Windows 95, on 28 July 1993. Regardless, Windows 95 did support preemptive multitasking for 32-bit processes only.
    – user477799
    Commented Aug 8, 2015 at 7:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .