0

Tried writing a batch file to shutdown my 2012 server, but ran into a weird issue. For example on 2008 a batch file like the following runs as expected:

cmd /c shutdown -s -t 0

On server 2012 when I click the batch file it continuously spawns cmd processes until I forcible close it. What gives?

red888
  • 4,183
  • 18
  • 64
  • 111
  • 3
    It's 2012's way of saying "Use Powershell" – TheCleaner Jul 30 '14 at 18:48
  • mmmk, but what is this? I tried googling this behavior, but didn't get anywhere. Is there a technet doc explaining this or something? What is this *called*- is it clear what I'm asking? – red888 Jul 30 '14 at 18:50
  • 1
    Also, kind of an obtuse way to handled this when they could have, I don't know, popped a message that says "Use Powershell". – red888 Jul 30 '14 at 18:53
  • 1
    @red888 I believe TheCleaner is being a bit facetious. Your script works fine for me on Server 2012 R2. Are you doing Run as Administrator on the batch file? The Powershell equivalent is `Stop-Computer`. – jscott Jul 30 '14 at 19:01
  • 2
    Also, every time someone uses cmd/bat on Server 2012, I kick a puppy. Keep it up and the neighbor kids are going to be distraught when their dog gets kicked to death. – HopelessN00b Jul 30 '14 at 19:25
  • Like @jscott said...I was being facetious. – TheCleaner Jul 30 '14 at 19:43

1 Answers1

5

when I click the batch file it continuously spawns cmd processes until I forcible close it.

Just out of curiosity, what did you name the script? Did you happen to name it shutdown.bat or shutdown.cmd perhaps?

If so, the script is calling itself because of how Windows resolves the path for commands. Use the full path to shutdown.exe, issue a CD command in your script, or rename your script.

Zoredache
  • 130,897
  • 41
  • 276
  • 420