Chef on Windows Tip: WinRM Bootstrap Failure – .bat not recognized

I hit the following error last week when attempting to bootstrap a Windows server over WinRM:

Creating new client for MYSERVER01
Creating new node for MYSERVER01

Waiting for remote response before bootstrap.MYSERVER01 .
MYSERVER01 Response received.
Remote node responded after 0.03 minutes.
Bootstrapping Chef on MYSERVER01
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 1
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 2
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 3
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 4
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 5
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 6
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 7
MYSERVER01 Rendering “C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat” chunk 8
MYSERVER01 ‘C:\Users\TEMP\AppData\Local\Temp\bootstrap-17856-1514391069.bat’ is not recognized as an internal or external command,
MYSERVER01 operable program or batch file.
ERROR: Failed to execute command on MYSERVER01 return code 1
ERROR: Bootstrap command returned 1

I googled with Bing and found a few posts with a similar error so I tried their solutions. 

  • Updated the knife gem on my workstation
  • Updated my ChefDK
  • Rebooted the target
  • Rebooted my workstation
  • Ran knife as a different user. 

Nothing worked. 

I eventually verified “C:\Users\TEMP\AppData\Local\Temp\bootstrap-….bat” path was being created during the bootstrap process but it looked like it was immediately deleted or couldn’t be accessed. 

During my troubleshooting I opened the file share to this path to watch and a side-effect was the next time I ran the bootstrap process is used another TEMP profile directory:

Rendering “C:\Users\TEMP~1.ACM\AppData\Local\Temp\bootstrap-17484-1514393770.bat” chunk 1

And wouldn’t you know, the bootstrap run got past the error. 

Not sure if there was something wrong with that specific profile or the real root cause but I got past the error.  Hoping this post helps other too.  If it does, please leave a comment below and share your experience.  Thanks!

Leave a Reply