How to tell forfiles to execute command in PATH?

自作多情 提交于 2020-01-02 02:34:06

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/508779/how-to-tell-forfiles-to-execute-command-in-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!