0

I'm trying to get a command to run in a cmd vindow via VBS. Just like this answer: How to keep the VBScript command window open during execution

The command I'm trying to issue is this, as written it works in a .cmd file.

"\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\dtexec" /x86 /f "\\path\folder\folder with space\Import.dtsx"

I've been unable to get it to work in the syntax from the above answer:

objShell.run "%comspec% /c ""SomeProgram.exe -R & pause""", 1, True

Figure it's a double quote issue, but I can't find it.

(I have to use the whole path to dtexec to force usage of the 16bit version.)

Followup: =======================================================

This works:

oShell.Run "%comspec% /C ""\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\dtexec"" /x86 /f c:\temp\Import.dtsx & Pause", 1, True

This does not:

oShell.Run "%comspec% /C ""\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\dtexec"" /x86 /f ""c:\temp\temp two\Import.dtsx"" & Pause", 1, True

nor this:

oShell.Run "%comspec% /C ""\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\dtexec /x86 /f c:\temp\temp two\Import.dtsx"" & Pause", 1, True

It's that space in the filename argument that is hosing it.

1 Answer 1

1

You don't need pause, just tell CMD to keep the window open after the command finishes (/k) instead of closing it (/c):

objShell.Run "%comspec% /k program.exe -R", 1, True

Nested double quotes are only required when you have a path with spaces in it, e.g.:

objShell.Run "%comspec% /k ""C:\some folder\program.exe"" -R", 1, True

Edit: If arguments in your commandline are paths with spaces as well you need quotes around each path and another set of quotes around the entire statement:

objShell.Run "%comspec% /c """"C:\some folder\program.exe"" /p ""foo bar"" & pause""", 1, True
Sign up to request clarification or add additional context in comments.

1 Comment

I wanted to use the /c syntax for the "press any key" to close. I got that working in my follow-up above. BUT when the filename argument also has a space, it will not work as I have it written. Tried every which way, clearly missing the right way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.