views:

831

answers:

2

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

A: 

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.

Noel
A: 

Another possible answer is to use the old 8.3 names you get by doing dir /X.

Like: C:\PROGRA~1 instead of C:\Program Files.