Batch file not executing properly

Posted on 2007-07-28
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
    LVL 19

    Accepted Solution

    unless soemthign else on the server is naems shutdown.

    try using the exact path to shudown.exe

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

    Author Comment

    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.
    LVL 1

    Author Comment

    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

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
    A quick step-by-step overview of installing and configuring Carbonite Server Backup.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now