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 

background, further reading


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -