By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Shell command with embedded Parentheses

P: 3
I am trying to construct a string that contains the following and set a string variable to its value as in:
Expand|Select|Wrap|Line Numbers
  1. strCommand = "C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager\"TLCcommander\vsqlcmd -d "C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager"\Data\tlc.vdb4 -o vsql.txt -h -1 -s "," -Q "Select * from asc_asset"
  2. shell strCommand
I've tried using double quotes, triple quotes in various combinations with no luck.

Any suggestions?
Feb 3 '14 #1

✓ answered by NeoPa

All double-quotes within your string literal value should be doubled up (and properly formulated of course). Try this :
Expand|Select|Wrap|Line Numbers
  1. strCommand = """C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager\" _
  2.            & "TLCcommander\vsqlcmd"" -d ""C:\Program Files (x86)\Tripwire\" _
  3.            & "Tripwire Log Center Manager\Data\tlc.vdb4"" -o vsql.txt -h -1 " _
  4.            & "-s "","" -Q ""Select * from asc_asset"""
  5. shell strCommand
Frankly, though I'm not sure of the syntax of the command, it does look wrong. What I suggest you do is get the write value for the string first. When you have an actual working version of the command you'd like to execute then copy/paste that in here and we can help with converting it into a VBA command to set the string up correctly.

Share this Question
Share on Google+
5 Replies


dsatino
100+
P: 393
Assuming your failure is in setting the string variable...

Change all of you double quotes to single quotes. Then wrap the entire string in double quotes
Feb 4 '14 #2

NeoPa
Expert Mod 15k+
P: 31,186
All double-quotes within your string literal value should be doubled up (and properly formulated of course). Try this :
Expand|Select|Wrap|Line Numbers
  1. strCommand = """C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager\" _
  2.            & "TLCcommander\vsqlcmd"" -d ""C:\Program Files (x86)\Tripwire\" _
  3.            & "Tripwire Log Center Manager\Data\tlc.vdb4"" -o vsql.txt -h -1 " _
  4.            & "-s "","" -Q ""Select * from asc_asset"""
  5. shell strCommand
Frankly, though I'm not sure of the syntax of the command, it does look wrong. What I suggest you do is get the write value for the string first. When you have an actual working version of the command you'd like to execute then copy/paste that in here and we can help with converting it into a VBA command to set the string up correctly.
Feb 4 '14 #3

P: 3
That worked perfectly. Appreciate the help. Just for grins, here is the command as run from a cmd window which also worked. It was the going from cmd window to code that I had the problem.

C:\>"C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager\"TLCcommander\vsqlcmd -d "C:\Program Files (x86)\Tripwire\Tripwire Log Center Manager"\Data\tlc.vdb4 -o c:\vsql.txt -h -1 -Q "Select * from asc_asset"
Feb 4 '14 #4

NeoPa
Expert Mod 15k+
P: 31,186
That's interesting. As a bit of a CMD fan myself, I was unaware that parts of a full file reference could be enclosed in quotes while the rest of it could follow outside of them. I'd assumed the whole reference needed to be within quotes for it to work. You'll see this reflected in the VBA I posted. The result is changed from your original for that very reason.

:-) I learned something today.
Feb 4 '14 #5

P: 3
As did I. I didn't think you could have the program name inside the quotes. I thought it would be considered part of the path.

Again, thanks for the assist.
Feb 4 '14 #6

Post your reply

Sign in to post your reply or Sign up for a free account.