Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell forfiles to execute command in PATH?

I'm missing something (obvious?) about escaping my strings or spaces in the following Windows Server 2k3 batch command.

FORFILES -m *.wsp -c "CMD /C C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^ -o^ addsolution^ -filename^ @FILE"

Results in the following error

'C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe -o addsolution -filename "foobar.wsp"' is not recognized as an internal or external command,operable program or batch file.

But I can't figure out why. I'm working off Mr. Simon Sheppard's fine documentation

like image 301
Noel Avatar asked Feb 03 '09 20:02

Noel


1 Answers

The path needs to be quoted, and the quote must be escaped.

FORFILES -m *.wsp -c "CMD /C ^0x22C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^0x22 -o^ addsolution^ -filename^ @FILE"

A co-worker suggested using the hex for ", and I eventually figured out that the hex needed escaping.

like image 196
Noel Avatar answered Sep 22 '22 10:09

Noel