Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Just saw this one fly by on an internal list and thought google might help someone find it someday:
Question: I have “myapp.exe a b” to be executed. How can I launch such command with CLR API?
Answer (a local smart guy): System.Diagnostics.Process.Start("myapp.exe", "\"a\" \"b\"");
Comments
- Anonymous
September 20, 2004
I don't believe you need the inner quotes. It should work fine like System.Diagnositics.Process.Start("myapp.exe", "a b"); If you pass it with quotes it would be equivalent to "myapp.exe "a" "b"".
Wes - Anonymous
September 20, 2004
The comment has been removed - Anonymous
September 20, 2004
I agree on both previous comments ;-) I don't see the need for the extra quotes and there's something weird about Process not living in e.g. System.Runtime or System.Threading.
Related to the Process.Start call: it gets fishy if you have a full commandline you want to run but not the exe name and the arguments separately. I came across this when trying to launch the default email client (see http://jelle.druyts.net/PermaLink.aspx?guid=b8e15df1-5948-4f87-a976-b858a65c9baa): I built in some basic argument extractor but it's not really clean since it just checks for a space - which would be incorrect if the exe name is quoted and contains spaces. Point being: there should be a Process.Start(string fullCommandLine) overload :-) - Anonymous
September 20, 2004
Whoops, scratch §2 in the previous comment: that wouldn't be possible of course since that method signature is already used for launching a process without any arguments. So I would opt for a "static ProcessStartInfo Parse(string fullCommandLine)" method on ProcessStartInfo. That would simply allow you to do
Process.Start(ProcessStartInfo.Parse(fullCommandLine)); - Anonymous
September 20, 2004
You can also use (and I prefer) the startInfo class and use the arguments property of it.
process.startInfo.arguments = "arguments here"
process.start() - Anonymous
September 20, 2004
The comment has been removed - Anonymous
September 27, 2004
I really hate System.Diagnostics not being in the .NET Compact Framework - it's always a little painful to see CF code have to recreate the Process.Start code with P/Invoke's. It's a cut I can understand, but I don't have to like it :) - Anonymous
September 27, 2004
Good news for you James... I just learned that this will be in V2.0 of the Compact Framework. It did not make it until Beta1, but it will be in Beta2 and RTM... - Anonymous
October 15, 2004
Brad,
It looks like [ProcessStartInfo.RedirectStandardOutput] flag doesn't work while used within Windows Service.
While writing Subversion backup service i've experienced that following code fills [backupData] string while called whithin Console app but produces no output/Exceptions while called within Windows Service (used context of admin user):
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = svnAdminPath;
psi.Arguments = arguments;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
string backupData = string.Empty;
try
{
Process process = Process.Start(psi);
backupData = process.StandardOutput.ReadToEnd();
process.WaitForExit();
}
catch (Exception ex)
{
EventLog.WriteEntry("SvnBackupSource", ex.Message, EventLogEntryType.Error);
}
Could you please provide some comments on the issue? - Anonymous
May 03, 2008
PingBack from http://kingston.cheapnewsguide.com/doesclrreallyclean.html