2

I am trying to run a command line in vb6 and it won't work because of a " character in the command.

Here is the code I can run in command line and it works but when doing it from the VB it gets screwed up.

AlarmSummaryUtility 10 TP=1;PT=4 "W h:m:s:F:p" /export

Following is VB script that does not work because I think the command already has "" around the one section:

Dim command As String
command = AlarmSummaryUtility 10 TP=1;PT=4 "W h:m:s:F:p" /export
shell "CMD.exe /c " & command
End Sub

The issue is that in the command I am trying to execute, it already has "W h:m:s:F:p".

Is there any other way to do this?

2

1 Answer 1

2

You need to enclose the quote with double quotes.

Dim command As String

command = "AlarmSummaryUtility 10 TP=1;PT=4 ""W h:m:s:F:p"" /export"
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! What if I want to add another command on the same line. I need to change directory first and then run the above command. Would I do the following with the & symbol? "cd c:\deltav\bin" & etc.
& converts and combines strings. For commands, I think you need to execute one and then the other. Or, you can just add the path to the original commands and have a single command. You can use & to make it more readable.
You can only combine commands if that would actually work on the real command line.

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.