passing a string into a command parameter

  • Thread starter Thread starter nologo
  • Start date Start date
N

nologo

hello chaps,
how can i pass a string value into a parameter to be called in a batch
script.
i'm building a archive function using 7zip, i wish to be able to
select a location to save which i was going to call in command line as
%1. the problem is getting the location to %1 within c#.

thanks in advance
 
Assuming you are using Process.Start, the Process.StartInfo.Filename property
should be cmd.exe, and the Process.StartInfo.Arguments should be the
batchfile and the arguments as a string separated by spaces, quoted as needed.
 
nologo,

Well, when you call the Process class, you can pass the program and the
command line to the static Start method, passing the arguments in the second
parameter:

Process process = Process.Start("7zip.exe", "\"c:\Documents and
Settings\Nick\myfile.txt\"");
 
Back
Top