vbscript - VBS How to call cmd.exe using a string variable with spaces -
i need call following:
set wshshell = wscript.createobject("wscript.shell") wshshell.run "cmd /c copy /y c:\input\" & wscript.arguments(0) & " c:\output", 0
where input argument may "file name.txt". have seen countless examples of people doing same thing using double quotes hard coded file location, nothing using input argument or variable. syntax required command line receives:
copy /y "c:\input\file name.txt" c:\output
and not
copy /y c:\input\file name.txt c:\output
for arbitrary file name?
embed needed quotes (escaped via doubling) in surrounding literals:
wshshell.run "cmd /c copy /y ""c:\input\" & wscript.arguments(0) & """ c:\output", 0
Comments
Post a Comment