We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Windows95 Shutdown processing

garna asked
Medium Priority
Last Modified: 2013-12-29
In Windows 3.1 Winstart.bat is used to run processes when windows is started but before it is loaded.  How do you do this sort of thing when you click on the shutdown button.  Alternatively, how can you shutdown without start-> shtudown or Ctrl-Alt-Del -> shutdown.  Is there a command or system call to do this?
Watch Question

Actually the easiest way to do it is to head to http://www.windows.com.  There you will find a lot of utilities and shareware, among them is a little program that runs a stay in your systray and when you click on it it will shut down windows.

Hope this helped

Here... I found the page for you:
one of them is ClickDown


I need that sort of functionality to be attached to the Start->shutdown or Ctrl-Alt-Del->Shutdown routine.

You mean you want to write a little program and propose it to Bill Gate so he could include it in his Windows 98 release??


So it can't be done then.  How then do Applications that need to restart windows95, actually cause the restart to happen.  There must be a way.

By invoking API. And since I'm not a programmer to know how they do it, I guess my answers will stop here.
I know what you want! but.... I'll keep looking, in the meantime maybe someone else will post an answer!
Garna: Windows 3.xx is a 16 bit application heavily intergrated with DOS conventions, whereas Windows 95 is a 32-bit application relying upon "api" interface and "ddl's". In addition, in windows 3.xx, as each application closed it performed it's own cleanup including dumping temp files etc, and moreover windows 3.xx did not use and dynamic programming hooks as does windows 95. On the other hand, windows 95 does not do all of this cleanup until after it has begun the shutdown process, whereupon it notifies every program running that they should close and clean up and then waits for an answer from each one.
To dynamically reboot windows 95 would cause the files in c:\windows\temp to be abandoned. You can develop an api interface to accomplish your task and do the cleanup, as
Microsoft has made available the windows 95 sdk to enable people to do just that. It's available as a free download.
Here's some info and an example:
The MSSetup Toolkit does not provide a way for the user to arbitrarily and cleanly reboot the computer without having the RestartListEmpty function return 0 (zero). The NSETUP sample provides a work around for this situation by providing a mechanism for the user to communicate with the
MSSetup dynamic-link libraries (DLLs) to cleanly reboot the computer without having a system file on the RestartList.
Download NSETUP.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
 - Microsoft Download Service (MSDL)
      Dial (206) 936-6735 to connect to MSDL
      Download NSETUP.EXE
 - Internet (anonymous FTP)
      ftp ftp.microsoft.com
      Change to the \SOFTLIB\MSLFILES directory
      Get NSETUP.EXE
The MSSetup Toolkit occupies a relatively small footprint in memory while providing much of the functionality needed to author a full-featured installation program. MSSetup accomplishes this low memory requirement by having a small fixed code stub program (SETUP.EXE) copy over the larger
DLLs to a temporary directory on the user's hard disk. When the script exits, this small fixed code stub cleans up after the installation script by deleting the DLLs from the user's temporary directory.
Another feature built into the MSSetup Toolkit is the ability to let the user install system level DLLs while they are loaded in memory at the time of installation. MSSetup accomplishes this by maintaining a list of files that need to be installed while Windows is rebooted. The MSSetup script author accomplishes this by calling the MSSetup functions RestartListEmpty and ExitExecRestart.
There is no functionality built into the MSSetup Toolkit, however, to allow the user to arbitrarily reboot Windows. A cursory examination of this situation might yield a workaround involving the call to Windows-based application programming interface (API) ExitWindows or ExitWindowsExec via the MSSetup script. However, there is a problem with this approach. Upon rebooting the system, the user will find all the MSSetup DLLs still present in the temporary directory. Because Windows exits more or less immediately upon the call to ExitWindows or ExitWindowsExec, the Setup stub program (SETUP.EXE) never has a chance to perform its cleanup (see paragraph above). To expect the installation script to provide this type of functionality further complicates the situation.
Another approach to the situation is to let MSSetup handle the cleanup as it would normally. NSETUP launches SETUP.EXE and waits for it to clean up and terminate. In this manner, NSETUP relies on SETUP.EXE's behavior to delete the files in the temporary directory. The sample also demonstrates a
technique for communicating between the MSSetup script and the NSETUP program via the Windows function RegisterWindowMessage.
In many ways, the NSETUP sample is similar to SETUP.EXE; it is a fixed code stub program, which WinExecs SETUP.EXE and then waits in the background for the program to finish. When SETUP.EXE finishes, NSETUP consults a reboot flag set via a message sent from the MSSetup script. If the user has chosen
to reboot, NSETUP makes a call to ExitWindows.
The Microsoft Visual Basic for Windows SendKeys function cannot be used to
close the Microsoft Windows Program Manager in order to terminate Microsoft
Windows. To correctly close Program Manager, you must invoke the
ExitWindows API function, as shown below.
Many software setup or installation programs are designed to exit Windows,
and then restart Windows when the setup or installation is complete. You
can make a Visual Basic program automatically exit Windows and then restart
Windows by passing the EW_RESTARTWINDOWS value to the ExitWindows API
function. The value for the EW_RESTARTWINDOWS constant is &H42.
You may want to terminate the current Windows session by closing the Program Manager from within a Visual Basic application. You may think that you can activate the Program Manager control menu and send the appropriate key sequences using the Visual Basic SendKeys function. However, this
method does not work because after the Close menu item is chosen, a system modal dialog box is opened that prompts you to save changes to Program Manager. A system modal dialog box locks out ALL other programs until it is satisfied. Therefore, the keystroke you send by using the SendKeys function
never arrives in the dialog box.
To correctly close Program Manager, you must use the ExitWindows API function. You can declare this API function in a code module name Module1.
Step-by-Step Example
1. Start a new project in Visual Basic.
2. Draw a command button on the form.
3. Add the following as a single line to Module1:

   ' Use for Windows 3.11 or Windows for Workgroups 3.11 applications:
    Declare Function ExitWindows Lib "user" (ByVal wReturnCode as Long, _
    ByVal dwReserved as Integer) as Integer
   ' Use for Windows 95 or Windows NT applications:
      Declare Function ExitWindows Lib "user32" alias "ExitWindowsEx" _
         (ByVal wReturnCode as Long, ByVal dwReserved as Long) as Long
4. Add the following line of code to the command button's Click procedure:
   ' Use for Windows 3.11 or Windows for Workgroups 3.11 applications:
      RetVal% = ExitWindows(0,0)
   ' Use for Windows 95 or Windows NT Applications:
      RetVal& = ExitWindows(0&, 0&)
5. Run the program.
6. Click the command button.
The ExitWindows API call initiates the standard Windows shutdown procedure. If all applications agree to terminate, the windows session is terminated and control returns to MS-DOS. If the ExitWindows API call fails due to an open MS-DOS session or for some other reason, FALSE is returned. You should
check for this return value and handle it appropriately.
Steps to Reproduce Behavior
1. Start a new Project in Visual Basic.
2. Draw a command button on the form.
3. In the command button Click event procedure, add this code:

   AppActivate("Program Manager")
   SendKeys "%{ }{DOWN 5}{ENTER 2}", 0  'ALT, SPACE, DOWN 5, ENTER 2
4. Run the program.
The Program Manager does not close. If you choose the OK button with the mouse, a message is displayed stating, "Can't quit at this time." If you choose the Cancel button, a message is displayed stating, "Cannot start more than one copy of the specified program." These messages are misleading, but are the result of attempting an unsupported action.
Additional reference words: 4.00 vb4win vb416 restart start exit windows
You can restart Windows from inside a FoxPro for Windows application by using the Windows API function ExitWindows(). With this function, you can restart Windows without rebooting the entire system, as explained below.
By using FOXTOOLS.FLL and the Windows API function ExitWindows(), you can restart Windows. The following code illustrates this concept.
NOTE: While it is possible to restart Windows from within a FoxPro for Windows program by making use of the Windows API function ExitWindows(), FoxPro may not do a complete cleanup and may leave *.TMP files in your SET
TEMP= subdirectory.
   *** Begin Code ***
   * WARNING: Make sure all work is saved before running code
   title="Program Message"
   msg="Would you like to restart Windows now?"
   IF choice=6    && button 'Yes' was chosen
      WAIT WINDOW "You have chosen not to restart Windows" TIMEOUT 2
   *** End Code ***
The ExitWindows() function requires two numeric values to be passed in and returns a single integer. The significance of the first integer (66) is that it is the decimal equivalent of 0x42 hexadecimal or EW_RESTARTWINDOWS, which is a low-order word in the C++ language. The second integer is
reserved and is always zero. When the ExitWindows() function is called, it sends a message to all active applications that a request has been made to restart Windows. If all applications "agree" to be terminated, the WM_ENDSESSION message will be sent to all applications before Windows is restarted.
Hope this helps you!

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.