Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I restart 95 from a batch file.

Status
Not open for further replies.

Quinny

MIS
Jan 20, 1999
6
0
0
GB
I would like to shutdown and restart a Win95 PC once a day in the wee small hours when no staff are using it.<br>
<br>
I believe you can shutdown Win95 using:<br>
<br>
rundll32.exe user32.exe, exitwindows<br>
<br>
Is there a way to shutdown ANDrestart?<br>
<br>
I will be running this from the Task Scheduler that comes with IE4 as I would prefer not to use any shareware utility.<br>
<br>
Thanks
 
Thanks, but I am sure this can be done without using Shareware.<br>
<br>
I believe it is some kind of API call to user32.exe.<br>
<br>
?
 
We had tried to use a command line API extraction type of Win95 restart also, but could not get it to work (that was why the shareware was so helpful). The closest we got was using a call to shell32.dll (I believe), but it only seemed to work on Win98 (?)
 
The API call to user32 can be implemented using Visual Basic.<br>
<br>
Use these declarations:<br>
Private Declare Function ExitWindowsEx Lib &quot;user32&quot; (ByVal uFlags As Long, ByVal dwReserved As Long) As Long<br>
<br>
Const EWX_REBOOT = 2<br>
<br>
Place the following in the startup form load event:<br>
Dim x As Long, Flags As Long<br>
x = ExitWindowsEx(EWX_REBOOT, Flags)<br>
<br>
Good luck.
 
How about an <i>easy</i> way..... ;)<br>
1. Get out your Win95 BOOT DISK<br>
2. Copy A:\reboot.com to C:\reboot.com<br>
3. Write your batch file to call reboot.com whenever you want....will shut down <i>AND</i> reboot your system.<br>
If you can't get to your boot disks; I'm sure I can scrounge mine up & e-mail it to you (only about a 1K prog.) <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= > </a><br>*nix installation & program collector/reseller. Contact me if you think you've got one that I don't :)
 
Thanks everybody, here's what I did.<br>
<br>
Since we only have MS Access as a programming language around here, I checked Technet article Q168796. This shows how to use the ExitWindowsEx function for either logging off, shutting down, rebooting with or without forcing programs to close, see below:<br>
<br>
Private Const EWX_LogOff As Long = 0<br>
Private Const EWX_SHUTDOWN As Long = 1<br>
Private Const EWX_REBOOT As Long = 2<br>
Private Const EWX_FORCE As Long = 4<br>
Private Const EWX_POWEROFF As Long = 8<br>
<br>
Private Declare Function ExitWindowsEx Lib &quot;user32&quot; _<br>
(ByVal dwOptions As Long, _<br>
ByVal dwReserved As Long) As Long<br>
<br>
I used the function as such:<br>
<br>
Private Sub ForceReboot_Click()<br>
ExitWindowsEx (EWX_REBOOT Or EWX_FORCE), &HFFFF <br>
End Sub<br>
<br>
I created an Autoexec macro to call the function when the database started. Then installed the Task Scheduler from IE4 and called the batch file at 23:59 every night. Should be interesting test for the millenium.<br>
<br>
All seems to be working okay. Thanks again.<br>
<br>
Q.<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top