Quotation marks in string arguments

B

bcastaing

My Windows service includes the following lines:

string Arguments3 = @"%OvAgentDir%\bin\OpC\cmds\ref-ovo-services.vbs
ServiceApplicatif ServiceOVO";
string expandedArguments3 =
Environment.ExpandEnvironmentVariables(Arguments3);
this.process3.StartInfo.Arguments = expandedArguments3;
this.process3.StartInfo.FileName = "cscript.exe";

ref-ovo-service.vbs runs with two arguments: ServiceApplicatif (windows
service) and ServiceOVO. Service applicatif can have a space in the
name.

My problem is to interger quotation marks on both sides of
ServiceApplicatif in the case of my Service Applicatif has a space.

\" on both sides of the command in this.process3.StartInfo.FileName =
"\"cscript.exe\""; works all right but not in string Arguments3

Thanks for any advices.
Bruno
 
C

Clive Dixon

You need to use double double quotes (if you see what I mean) in verbatim
strings to represent a single double quotes.

"\"cscript.exe\""

but if prefixed with @,

"""cscript.exe""";
 
B

bcastaing

Hi Clive,

Thanks for answering

I gonne test right now with 2 quotes

string Arguments3 = @"%OvAgentDir%\bin\OpC\cmds\ref-ovo-services.vbs
""ServiceApplicatif"" ServiceOVO";

Have a good day
Bruno
 
Top