1

I need to call the following:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd /c copy /y C:\input\" & WScript.Arguments(0) & " C:\output", 0

where the input argument may be "File Name.txt". I have seen countless examples of people doing the same thing using double quotes for a hard coded file location, but nothing using an input argument or variable. What syntax is required so that the command line receives:

copy /y "C:\input\File Name.txt" C:\output

and not

copy /y C:\input\File Name.txt C:\output

for an arbitrary file name?

1 Answer 1

3

Embed the needed quotes (escaped via doubling) in the surrounding literals:

WshShell.Run "cmd /c copy /y ""C:\input\" & WScript.Arguments(0) & """ C:\output", 0

background, further reading

Sign up to request clarification or add additional context in comments.

1 Comment

That worked perfectly, I can't believe I wasn't able to figure that out. Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.