HighTechTalks DotNet Forums  

RE: Defining a variable which includes quotes - how???

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss RE: Defining a variable which includes quotes - how??? in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Conic Ellipse
 
Posts: n/a

Default RE: Defining a variable which includes quotes - how??? - 10-22-2004 , 03:35 PM






"Lost in Space" wrote:

Quote:
I have to pass control from my script to the Windows "Find" command. FIND
requires that you pass it the information you would like to find using "".
Here is the command structure :
Const strLaunchCmd = "cmd.exe /k dir c:\ /s /b | find /i "string"
output.txt"

VB errors out on the quotes around string - is there a way to pass this
command without VB erroring out? I know some scripting languages allow you
to place special characters around "" to enable them to be used in this kind
of situation - does VB have the same capabilities?

Thanks...
I don't see any replies to your post. It's been a few months since this post
was placed but I figured I would post a reply just for posterity.

When using quotes, you usually have to use them in pairs. For each opening
quote, you must have a closing quote. If you have an odd number of quotes,
there's a good chance you'll have a problem.

To pass quotes to a command line, as in the case of your FIND command, you
need to enclose the quotes, in QUOTES. In other words, when you need to pass
a parameter in quotes, put 3 sets of quotes around each side of the
parameter. So, in your example above, try:

Const strLaunchCmd = "cmd.exe /k dir c:\ /s /b | find /i """string""" " >
output.txt"


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.