How do I launch a process with parameters

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.
 
S

Scott M.

system.diagnostics.process.start("C:\Program Files\Create File.exe" -c -s
1500 Mb -t 0 "C:\temp folder\File Created.tmp")
 
J

Josip Habjan

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
 
G

Guest

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
 
P

Phil Wilson

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top