Batch file not executing properly

Posted on 2007-07-28
Medium Priority
Last Modified: 2010-05-18
I am using a batch file to restart one of my W2K3 servers using task scheduler.

One one server, it works fine. I tried to use the same exact batch file to reboot another server, but when the batch file runs, instead of rebooting, a command prompt window opens and the command just runs over and over again until the command prompt is closed. If I type the command in at the command prompt instead of running the batch file, it works just fine.

Both the servers are W2K3 machines with SP1 installed.

The batch file is a single line: shutdown /r /t 120
Question by:porkerjoe
  • 2
  • 2
LVL 19

Accepted Solution

William Elliott earned 1000 total points
ID: 19585966
unless soemthign else on the server is naems shutdown.

try using the exact path to shudown.exe

c:\windows\shutdown.exe /r /t 120

Author Comment

ID: 19586003
That did not work, however, with the change you suggested the command did not loop over and over again in the command prompt window, it simply opened a command prompt and then closed it.

On the first server (the machine that is working), you don't even see the command prompt open.

Remember also that I said that if I type in shutdown /r /t 120 at a command prompt on the second machine it works just fine.

Author Comment

ID: 19586026
More info:

I looked in c:\windows and there is no such file as shutdown.exe

I renamed the batch file from shutdown.bat to shutdown.cmd - no change.

I then altered the script from: shutdown /r /t 120

to: shutdown.exe /r /t 120

Then it started working.

I renamed it back to shutdown.bat (just curious...) and it still works.

So for whatever reason, it needed the .exe on the end of it
LVL 19

Expert Comment

by:William Elliott
ID: 19586306
ah,. you answered your own question..
it depended on where the batch file was being called from.

it looped because the batchfile was calling itself over and over again.
had i known the name of the batch file i would have suggested just changing it to some othername.

glad you got it working.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question