Shutdown command in batch file

G

Guest

I am trying to use the following shutdown command in a batch file to shutdown
computers on a network.
shutdown -s -f -t 00 -m \\computername
The command works fine when issued from the command prompt, but when I run
it as a batch file only the first line runs in a continuous loop.

Any ideas as to why?
 
G

george

Bill said:
I am trying to use the following shutdown command in a batch file to
shutdown
computers on a network.
shutdown -s -f -t 00 -m \\computername
The command works fine when issued from the command prompt, but when I run
it as a batch file only the first line runs in a continuous loop.

Any ideas as to why?

you wouldn't happen to have your batch file named shutdown.bat, would you?
If so, rename it to something slightly different from "shutdown"

hth

george
 
G

Guest

Yes I had named the file Shutdown.bat. I renamed it test.bat and got the
same results. I shortned the file to the following:
echo on
rem this is a test
shutdown -r -t 00 -m \\computername
rem this is a test line 4
echo on

The first line processed. The second lined processed. The third echoed to
the screen but did not do anything. The next thing I received was an echo
off command. I don't know where that came from.
 
G

george

I suggest you name the file <something, but not shutdown>.cmd.
That way it will be processed bij the native windows command processor and
not through the NTVDM (Virtual dos machine!) command processor running in a
16-bit environment. That environment has a different setup, notably a
different PATH.

The reason why the shutdown didn't do anything might be because there was
some application running on that machine and you didn't specify the -f
switch?

hth
george
 
P

Pegasus \(MVP\)

Not quite. The extension of the batch file has no effect on
the virtual DOS machine. It's the applications themselves that
matters: 16-bit applications (e.g. debug.exe) will launch
the ntvdm.exe, 32-bit applications won't.

You can try this yourself. Check the Task Manager to
ensure that ntvdm.exe is not running, then launch two
identical batch files named test1.bat and test2.cmd. Each
should have this command inside: xcopy /?. You will find
that neither spawns ntvdm.exe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top