How do I launch a process with parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to launch a process within .NET (C#) with parameters.
I have temporarily gotten around this issue by writing this command to a
batch file & launching the batch file without arguments, but would like to
launch it directly from .NET.
My process looks like something like this:
"C:\Program Files\Create File.exe" -c -s 1500 Mb -t 0 "C:\temp folder\File
Created.tmp"
I got the samples working, such as launching notepad with a file, or
launching IE with a URL but the above command did not work.
Any help will be greatly appreciated.
 
system.diagnostics.process.start("C:\Program Files\Create File.exe" -c -s
1500 Mb -t 0 "C:\temp folder\File Created.tmp")
 
or:
Dim psi As New ProcessStartInfo
psi.FileName = "C:\Program Files\Create File.exe"
psi.Arguments = "-c -s 1500 Mb -t 0 " + Chr(34) + "C:\temp
folder\File Created.tmp" + Chr(34)
Process.Start(psi)

Regards,
Josip Habjan
URL: http://www.habjansoftware.com
 
I had tried that, and I keep getting an error: "System cannot find file
specified", as soon as I tried to insert any arguments such as: -c. Please
help.

This works fine:
System.Diagnostics.Process.Start(@"C:\Program Files\Create File.exe")

This does not (throws 'System cannot find file specified' error):
System.Diagnostics.Process.Start(@"C:\Program Files\Create File.exe -c -s
1500 Mb -t 0 c:\temp\tempfile.tmp")

Please help if you know how to get around this.

Swami
 
You've got your command line parameters included in the program name in the
quoted string. Do the ProcessStartInfo thing with the Filename and Arguments
separated as in the VB example.
 
Very helpful. That worked. Thanks.

Phil Wilson said:
You've got your command line parameters included in the program name in the
quoted string. Do the ProcessStartInfo thing with the Filename and Arguments
separated as in the VB example.
--
Phil Wilson [MVP Windows Installer]
----
Swami said:
I had tried that, and I keep getting an error: "System cannot find file
specified", as soon as I tried to insert any arguments such as: -c. Please
help.

This works fine:
System.Diagnostics.Process.Start(@"C:\Program Files\Create File.exe")

This does not (throws 'System cannot find file specified' error):
System.Diagnostics.Process.Start(@"C:\Program Files\Create File.exe -c -s
1500 Mb -t 0 c:\temp\tempfile.tmp")

Please help if you know how to get around this.

Swami
 
Back
Top