Log in

View Full Version : Shutdown a machine from a dos batchfile?


DDogg
19th January 2006, 23:22
Hope one of you admin types might know an answer.

I am using a ghost -clone command line on a bootable floppy in the autoexec.bat for a poorman's mirror - I would very much like to shutdown the machines after the disk to disk image is completed. This is being used on 25 machines, at night, at a foodbank where I volunteer - They need to save every penny they can. Any way to do this from within the autoexec.bat calling an external dos program of some type to shutdown the machine?

Would really appreciate some help on this one.

DDogg

random asshat
20th January 2006, 00:30
To the best of my recollection there is not a "native" routine
built into the DOS Command.com interpreter to shut down
a machine.

To do this, I always had to have an external program to
call upon to bring the machine to halt.

If your boot image can accomodate another small program,
some routines to accomplish this are described here (http://www.robvanderwoude.com/shutdown.html)

neo squidward
20th January 2006, 00:43
Here is something that says its for os/2 but people say it works for dos too.
ftp://ftp.kruemel.org/teil1/os2util/SHTDWN16.ZIP

DigitAl56K
20th January 2006, 01:57
You can also log onto the machine with the net command and shut it down with the shutdown command.

NET USE \\machine\IPC$ <password> /USER:<machine>\Administrator
SHUTDOWN -s -f -m \\<machine>

That should do it. I think :)

DDogg
20th January 2006, 06:52
Thanks very much for the replies. It would have been better if I had taken the proper time to state I have to use PC-Dos as ghost.exe will not fit on a single floppy with anything else I have found. Also, many of of these machines are stand-alone.

I was hoping there was just some small and simple dos shutdown program I could call from the batchfile after ghost completed.

I have spent quite a bit of time researching, but no luck so far. One can use a debug sequence to trigger a reboot, but I have not found a debug method, or small com/exe to turn the machine off.

I tried a couple of older shutdown.com type programs for ATX, but they also failed to shutdown these more modern machines. Frankly I am starting to think there is no way to do this.

Continuing to hope I will come up with something in my research, or a reader will post a solution.

Thanks again.

DD

DigitAl56K
20th January 2006, 07:29
Thanks very much for the replies. It would have been better if I had taken the proper time to state I have to use PC-Dos as ghost.exe will not fit on a single floppy with anything else I have found.

Use a ramdrive driver and a freeware compression tool. Keep everything on the floppy in a compressed archive except the bare minimum you need to set up the ramdrive and extract the compressed archive to it, then continue using the unpacked programs loaded onto the ramdrive.

I've done this before, works great. In fact, if you pack the files on the floppy you often boot faster because you're reading less data from a slow device.

random asshat
20th January 2006, 07:42
My (admittedly limited) understanding of calling a system halt
from software, is that it requires an ACPI compliant BIOS on the
machine that is supposed to be shutdown. Which is why you
may not find a wealth of utilities written for the early DOS era
machines and their OS to be powered off from the command line.

The two I would have suggested , you've probably
tried already. fdAPM (http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/fdapm/) and Shutdown (http://www.opus.co.tt/dave/shut12.zip)

I can throw a few other ideas at you:

If any of the machines have CD-ROM drives: download a self
booting OSS Ghost (http://sourceforge.net/projects/g4l) image ,
and include a bash script which atuomates the process
then calls "shutdown".

Wall outlet timers can be purchased relatively inexpensively from
your local "home improvement" warehouse. While I agree this is
not the "best solution" it would achieve your goal of saving energy
costs and wear on the hardware.

I'll continue to keep an eye out for a utility that fits your needs.

DDogg
20th January 2006, 17:18
Use a ramdrive driver and a freeware compression tool... Great suggestion - thanks!

... The two I would have suggested , you've probably tried already. fdAPM (http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/fdapm/) and Shutdown (http://www.opus.co.tt/dave/shut12.zip)
<snip> I had not found the fdapm - it works like a charm ... only 7k and deals with modern machines ... Really decent of you to take the time to search that out - problem solved. I knew my old friends on doom9 would know the answer if anybody did. Thanks a million!

auenf
25th January 2006, 13:10
windows xp comes with a commandline shutdown app


C:\Documents and Settings\David>shutdown
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)


Enf...