Shutdown batch file: endless command repetitions

paul1149

Member
Hi,

I've got a strange problem with Vista Biz. Most batch files work fine, but any one involving the shutdown command are spinning their wheels by repeating the command endlessly:

shutdown /s

shutdown /s

shutdown /s

shutdown /s
(There is a blank line between echos.)

The machine has no problem shutting down, just not by batch file. The same holds true for other switches than /s, such as /a and /r. I've had a /t 10 at the end of the command line, and it doesn't help.

When I called up the shutdown GUI (/i), the Ok button was grayed out, because no computer was selected. When I clicked Browse, I got an Active Directory ~not available~, or some such. I'm on a workgroup, not a domain (though the machine used to be on a domain), so I don't see how this matters.

This used to work. Then I used FileTypesMan to change the edit verb for batch files from notepad to metapad. Somehow that broke it. Switching back didn't help. So I downloaded the Vista batfile reg fix, and merged it. That fixed it.

But that was last week. The problem returned today with nothing having been changed. And the reg fix does nothing now.

Very puzzling.

Be well,
Paul
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Hello Paul and welcome to the forums :party:

That is odd!

Let's see if we can find any problems :)

SFC Scan

1. Open the start menu
2. In the search box, type cmd
3. Right click on cmd and select Run as administrator
4. In command prompt, type:

sfc /scannow

5. Let it run and let me know if it finds any Integrity Violations

Repeat that process with the following command:

Code:
sfc /scanfile=%SYSTEMROOT%\System32\shutdown.exe

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
Hi Tom,

Thanks, that was a brilliant idea, one I should have thought of. However, I'm getting "Windows Resource Protection found corrupt files but was unable to fix some of them." Then the log of the action is 404 impenetrable KBs. I don't know why the files couldn't be replaced, and the problem isn't fixed. I ran the command under an elevated prompt.

Paul
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Paul,

Sometimes, for whatever reason, it takes a few times to repair the file, so run that command 3 more times and we'll hope for the best :)

Once you've run the command, I would like you to do the steps in the yellow box at the top of this tutorial:

http://www.vistax64.com/tutorials/66978-system-files-sfc-command.html

Step one about reading the CBS log, can you attach the sfcdetails.txt with your next post please?


Then I would like you to download SystemLook (by jpshortstuff) to your desktop:

SystemLook Usage Guide

Then run it as an administrator and when it opens, copy and paste the following into the textbox and press Look:

Code:
:filefind
shutdown.exe

This will take a while to complete, but when it does, it will open up a text file in notepad. Can you copy and paste the contents of this into your next post please?

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
Hi Tom,

Thanks for getting back, and for your attention to this problem.

Excellent tutes by Brink, again. After several SFC runs, the log had tripled in size, to 1.3MB. When I ran Brink's reduction command, it came down to 118KB. I noticed that there was a lot of repetition, so I isolated the last iteration only. Then I ran a reduction command using "Cannot repair" as the filter, which I named mysfcdetails.txt. I'll include both the original and my redacted version here, and the SystemLook output.

The problem seems to be trivial in nature, in that only media files are not registered correctly (I frankly doubt that they are corrupted). But I can't get to it, as even after taking ownership of the Media folder, and granting full control to myself, I cannot overwrite or directly delete some of these files. I'm not sure why that is. I doubt that they're in use.

Thanks again,
Paul
 

Attachments

  • sfcdetails.txt
    184.2 KB · Views: 38
  • mysfcdetails.txt
    6 KB · Views: 44
  • SystemLook.txt
    1.1 KB · Views: 34

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Well at least you haven't got a problem with any of your core Windows files.

I would like you to go to:

C:\Windows\system32

And rename shutdown.exe to shutdown.exe.old

Then I would like you to copy the shutdown.exe from here:

C:\Windows\winsxs\x86_microsoft-windows-shutdown-event-tracker_31bf3856ad364e35_6.0.6001.18000_none_02d417b0c7f7f7ee\shutdown.exe

Into the system32 folder

Then see if it works :)

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
I had to change ownership and permissions to do that, and got it done. But it still doesn't work.

Very strange problem, considering that it worked fine on this machine just recently, with no apparent changes in between.
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
That's really weird, I can't think what else could be causing this problem

Have you tried disabling your anti virus?
Have you tried disabling UAC?
Have you had any problems with malware in the past? Or are you aware of any, or have any suspicions, that you have some at the moment?

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
AVG makes no difference, and UAC is already off. No malware that I'm aware of, but the machine is new to me.

This machine is a dream in every other way. I had heard a lot of bad about Vista, but I find it to be excellent.

It's odd that in a command window, the shutdown command works perfectly. The problem lies in how explorer reads the batch file, evidently, and I wonder if that blank line between repetitions is a clue. Reverting the registry's batfile Open verb to the original solved the problem at first. But now that's not working anymore.

I just created a test shutdown /a batch file, from scratch in Notepad, not using my normal metapad at all. Still has the problem.

Edit:
  • confirming, a shutdown /i batch file in C:\ calls up the GUI when clicked.
  • The batch in the Public desktop does not work.
  • If I leave the batch in C:\ and create a desktop shortcut to it, clicking the shortcut does work.
  • Adding my desktop to the Path did nothing.
For some reason Vista does not want a shutdown batch file on my desktop.
 
Last edited:

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Here's a clue. I just created a test.bat, shutdown /a, in notepad and saved it to the C:\ drive. It worked in a command window, and clicking on it flashed a command window on the screen, which probably means it fired correctly.

Then I took that same file and dragged it to desktop, and clicked it. The command window opened and began its endless iterations.

Another clue: Despite whatever command flag I put in the batch file, when I freeze the command window it shows shutdown /s.
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
This is really strange! I've never heard of anything like this. I'm going to have to ask for help on this one, someone here might know something about it :)

Does a shutdown /s batch file hang when its saved in C:\ ?

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
Yes, just tested a shutdown /s followed by a shutdown /a, both in C: fired via shortcuts on the desktop.

I wonder if permissions come into play here. I have to compare the two locations. Will get back.
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
I don't see a permissions problem. For some reason the "Allow" check boxes are grayed out. But they are checked. I have no idea at this point...
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Ok, this works:

c:\windows\system32\shutdown.exe /r

%SystemRoot%\system32 is in the Path statement. Somehow the shell is misinterpreting the command. My registry has:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"

Where Open is the default command being fired.
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Hello!

[DEL]This is actually a bug in Vista[/DEL], and it happens on quite a few people's machines, including mine :p [DEL]Interestingly, so far, I have only ever seen cases of this happening with shutdown .exe.[/DEL]

On my machine at least (see screenshot), the use of shutdown -a is ineffective, and a shutdown has NOT been initiated, it would seem!

I have never actually spent any time investigating this before, but I will now. I shall re-read this thread, and have a play with my computer, but I can make no promises or time promises...

shutdown.jpg

Richard
 
Last edited:

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Hello!

This is actually a bug in Vista, and it happens on quite a few people's machines, including mine :p Interestingly, so far, I have only ever seen cases of this happening with shutdown .exe.

On my machine at least (see screenshot), the use of shutdown -a is ineffective, and a shutdown has NOT been initiated, it would seem!

I have never actually spent any time investigating this before, but I will now. I shall re-read this thread, and have a play with my computer, but I can make no promises or time promises...

View attachment 24340

Richard

Scrap that! My machine is fixed! Just remembered something about batch files. You may never name them to the same as any one of your external commands.

In this example, the external command is shutdown.exe, and so the .bat file CANNOT be called shutdown.bat. Rename it to shut.bat for me, and tell me if the problem persists :)

Richard
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
On my machine at least (see screenshot), the use of shutdown -a is ineffective, and a shutdown has NOT been initiated, it would seem!

Hi Richard,

If your machine subsequently did not turn off, then that screenshot shows the a flag to be effective, but the previous shutdown command, if there was one, not to have been effective. If there was no shutdown in action, that is the response the a flag will properly make.

But if there was a shutdown in action, then the a flag was wrong not to recognize it. That would be a different problem than I have here.

Just remembered something about batch files. You may never name them to the same as any one of your external commands.

In this example, the external command is shutdown.exe, and so the .bat file CANNOT be called shutdown.bat. Rename it to shut.bat for me, and tell me if the problem persists :)

I thought of that early-on. I renamed my files to things like re_sta rt.bat and abort shut down.bat, and it affected nothing. And hard-linking shutdown.exe works in these bats, so the bat name cannot be the problem.

Thanks,
Paul
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Hello Paul,

I still believe that it has the same cause as I described above. I reason that you have multiple batch files by this point...

On my machine at least (see screenshot), the use of shutdown -a is ineffective, and a shutdown has NOT been initiated, it would seem!

Hi Richard,

If your machine subsequently did not turn off, then that screenshot shows the a flag to be effective, but the previous shutdown command, if there was one, not to have been effective. If there was no shutdown in action, that is the response the a flag will properly make.

But if there was a shutdown in action, then the a flag was wrong not to recognize it. That would be a different problem than I have here.

Just remembered something about batch files. You may never name them to the same as any one of your external commands.

In this example, the external command is shutdown.exe, and so the .bat file CANNOT be called shutdown.bat. Rename it to shut.bat for me, and tell me if the problem persists :)
I thought of that early-on. I renamed my files to things like re_sta rt.bat and abort shut down.bat, and it affected nothing. And hard-linking shutdown.exe works in these bats, so the bat name cannot be the problem.

Thanks,
Paul

I generated several different scenarios on my machine, for example turning shutdown -a into a streaming shutdown -s -t 60, and I understood them all.

However, I only explained one of them. Basically, in the screenshot above, a shutdown was never initiated, and -a worked perfectly. This was because it was launching the batch file recursively, and not shutdown.exe, shutdown.exe was never launched, and so -a had no work to do.

Here's a clue. I just created a test.bat, shutdown /a, in notepad and saved it to the C:\ drive. It worked in a command window, and clicking on it flashed a command window on the screen, which probably means it fired correctly.

Then I took that same file and dragged it to desktop, and clicked it. The command window opened and began its endless iterations.

Another clue: Despite whatever command flag I put in the batch file, when I freeze the command window it shows shutdown /s.

This can be explained away. It is all about multiple .bat files.

This is exactly what will happen if you have a .bat file on your Desktop called shutdown.bat, with contents shutdown /s. Go and delete this batch file, re-run those above tests, and you should not experience the same results.

Also, your current comparisons between batch and command window are flawed. You are not running them out of the same directory. This is crucial! You need to change the working directory of your Command Prompt.

Ok, this works:

c:\windows\system32\shutdown.exe /r

Because you are not specifying a path, effectively changing paths AND specifying explicitly.

You need to go and delete EVERY batch file, and start from scratch, and then it should work. If you don't do this, the below examples won't work.

Reproducible methods (done theoretically, and not tested - hopefully there aren't too many mistakes!)

Convention used is:

Scenario number: batch file name: location: contents

1: ShuttingDown.bat: DESKTOP: shutdown /s

Should work fine.

2: shutdown.bat: DESKTOP: shutdown /s

Execute .bat file: scrolling "shutdown /s"

From Command Prompt, not elevated (starts at %UserProfile% (eg C:\Users\Richard)):

shutdown /s

Works correctly.

cd %UserProfile%\Desktop\
shutdown /s


scrolling "shutdown /s"

3: shuttingdown.bat: DESKTOP: shutdown /s

shutdown.bat: %UserProfile% (eg C:\Users\Richard): shutdown /r

Execute batch file from Desktop, works correctly.

From Command Prompt, not elevated (starts at %UserProfile% (eg C:\Users\Richard)):

shutdown /s

scrolling "shutdown /r"

4: shutdown.bat: %UserProfile% (eg C:\Users\Richard): shutdown /s
shutdown.bat: %UserProfile%\Desktop (eg C:\Users\Richard\Desktop): shutdown /s

Execute Desktop batch file, scrolling "shutdown /s".

From Command Prompt, not elevated (starts at %UserProfile% (eg C:\Users\Richard)):

shutdown /a:

scrolling "shutdown /s".

I am still convinced that this is your problem. I shall test and correct the above scenarios soon.

Richard
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
OK, just tested them (albeit all with "/t 60" appended), and they look to be correct, scrolling as I would expect. However, there may still be mistakes in there :)
 

My Computer

System One

  • Manufacturer/Model
    Dell XPS 420
    CPU
    Intel Core 2 Quad Q9300 2.50GHz
    Motherboard
    Stock Dell 0TP406
    Memory
    4 gb (DDR2 800) 400MHz
    Graphics Card(s)
    ATI Radeon HD 3870 (512 MBytes)
    Sound Card
    Onboard
    Monitor(s) Displays
    1 x Dell 2007FP and 1 x (old) Sonic flat screen
    Screen Resolution
    1600 x 1200 and 1280 x 1204
    Hard Drives
    1 x 640Gb (SATA 300)
    Western Digital: WDC WD6400AAKS-75A7B0

    1 x 1Tb (SATA 600)
    Western Digital: Caviar Black, SATA 6GB/S, 64Mb cache, 8ms
    Western Digital: WDC WD1002FAEX-00Z3A0 ATA Device
    PSU
    Stock PSU - 375W
    Case
    Dell XPS 420
    Cooling
    Stock Fan
    Keyboard
    Dell Bluetooth
    Mouse
    Advent Optical ADE-WG01 (colour change light up)
    Internet Speed
    120 kb/s
    Other Info
    ASUS USB 3.0 5Gbps/SATA 6Gbps - PCI-Express Combo Controller Card (U3S6)
Wow, that was an awesome analysis. I don't understand all of it yet, but I do get that the shutdown.bat on my desktop was being targeted by other bats with the shutdown command in them (that explains seeing the /s flag in every readout). I didn't think this was an issue, because I also had tried running Re_start.bat as an administrator, which I thought sets the working directory to system32. But indeed, changing the name of shutdown.bat immediately solved the problem (without rewriting all the bats).

As for the rest, it seems like deep waters to me, but I'll try to parse it later, and I'll get back if a light turns on. Thanks very much for some very astute troubleshooting!

Paul
 

My Computer

System One

  • Manufacturer/Model
    dell precision
    Memory
    2G ddr2
    Graphics Card(s)
    matrox
Back
Top