Computing.Net > Forums > Disk Operating System > Batch files at shutdown

Batch files at shutdown

Reply to Message Icon

Original Message
Name: john lewery
Date: May 9, 2001 at 04:44:12 Pacific
Subject: Batch files at shutdown
Comment:

I would like to automatically run a DOS batchfile at windows98 shutdown- can anyone give me any ideas?


Report Offensive Message For Removal


Response Number 1
Name: Laurence
Date: May 12, 2001 at 10:07:05 Pacific
Subject: Batch files at shutdown
Reply: (edit)


Batfiles: The DOS batch file programming handbook

alt:msdos.batch

Sure, I do it all the time with both Win 3.1 and 4.1 (a.k.a. 98).
Run Windows from a batch file (autoexec.bat) instead of letting
it start automatically. When Windows is closed, your autoexec.bat
will continue where it left off and you can do as you like.

See here:
Windows 95/98/ME Complete MSDOS.SYS Reference

You may also need to hack win.com to beat it into shape (I did).
I start Windows only when I want to, and when I close Windows I
have real DOS (entering exit does NOT start Windows).



Report Offensive Follow Up For Removal

Response Number 2
Name: Laurence
Date: May 12, 2001 at 10:08:54 Pacific
Subject: Batch files at shutdown
Reply: (edit)

Ok, that url didn't take, here it is again:
Windows 95/98/ME Complete MSDOS.SYS Reference


Report Offensive Follow Up For Removal

Response Number 3
Name: John Lewery
Date: May 14, 2001 at 03:10:55 Pacific
Subject: Batch files at shutdown
Reply: (edit)

Thanks Laurence I figured it would be
something simple !


Report Offensive Follow Up For Removal

Response Number 4
Name: tsuji
Date: May 23, 2001 at 15:13:40 Pacific
Subject: Batch files at shutdown
Reply: (edit)

I have read this thread a week ago. I said I don't think it is a good idea to run windows under the control and with an additional instance of command.com in action. Hence the proposed solution by Laurence is far from satisfactory and, in fact, unsatisfactory.

I now find time to write up here a solution.

Everybody knows, if not read the Howtos of computing.net, how to construct the fully 32-bit lnk/icon for system shutdown via the commandline, namely,

rundll32.exe shell32,SHExitWindowsEx 1
or
rundll.exe user.exe,ExitWindows

As we target win98, I will stick to the first commandline hereinafter.

Now, the problem of the standard construction seems to be barring a multiple line shutdown process whereby some pre-shutdown batch job can be done before actual shutdown all by one click on an icon. That is why the question raised by John Lewery.

There are many way I can think of to accomplish this. The one (in fact, two) I propose here bears the most resemblance of the standard construction.

[1] Make a batch file, say Master.bat with the following construction :

call [drive:][path]\Slave.bat
rundll32.exe shell32,SHExitWindowsEx 5

Note : Why parameter 5, instead of 1? Because, as you will experience by yourself, if you use parameter 1, there will be an annoying popup window before shutdown asking you to exit the batch file under the virtual Dos machine. With 5, the exit will be forced which will give you the most satisfaction without bothering with the popup.

[2] Make another batch file, Slave.bat in the [drive:] and [path] as specified in the call statement in [1].

::-----Slave.bat-------
:: All the pre-shutdown house-keep jobs here
...
... all the batch job commands
...
::---------------------

[3] With Master.bat, make the pif/icon. The only detail you have to be careful, which is taken care of by default in fact, is to let the dos box sees the windows background in the advanced program setting. This is to assure that the 32-bit rundll32 etc run properly.

Now, you have got the job done. Just cut and paste the pif/icon to the desktop and the job is accomplished one click away.

A slight variation of the above construction is to keep only the rundll32 line in Master.bat, say, Master1.bat with one line only :

rundll32.exe shell32,SHExitWindowsEx 5

and specify the Slave.bat in the Master1.bat shutcut/icon program setting, namely,

cmdline : [drive':][path']\Master1.bat
and
batch file : [drive:][path]\Slave.bat

You accomplish the same.

Here you are. I can propose another solution without appealing to Dos batch file but instead using Windows SH. But that would be another story.

PS : I've edited the above in the little box, so my prose may be broken at places. But, you get the idea.


Report Offensive Follow Up For Removal

Response Number 5
Name: Laurence
Date: May 25, 2001 at 14:41:58 Pacific
Subject: Batch files at shutdown
Reply: (edit)

Food for thought.
I will be doing some thinking :-).


Report Offensive Follow Up For Removal


Response Number 6
Name: John
Date: September 5, 2001 at 01:26:30 Pacific
Subject: Batch files at shutdown
Reply: (edit)

After installing Linux (For which PnP OS was disabled in BIOS) Setups will not run from CR ROM Drive (in Windows) Double clicking on "Setup" is ignored. If PnP is reset then Linux will not load.
is there a work arround?


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch files at shutdown

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge