Use Process.Start with parameters AND spaces in path

Even when you use the ProcessStartInfo Class, if you have to add spaces for arguments, then the above answers won’t solve the problem. There’s a simple solution. Just add quotes around arguments. That’s all. string fileName = @”D:\Company Accounts\Auditing Sep-2014 Reports.xlsx”; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = “Excel.exe”; startInfo.Arguments = “\”” + fileName + … Read more

How can a Windows Service start a process when a Timer event is raised?

You’re adding descriptions of the problem in the comments as you go along that would have been helpful to know at the outset. The reason that you can see the process has started but no window ever gets opened is because of security model changes that were made to Windows Services under Windows Vista and … Read more

How can I run an EXE program from a Windows Service using C#?

This will never work, at least not under Windows Vista or later. The key problem is that you’re trying to execute this from within a Windows Service, rather than a standard Windows application. The code you’ve shown will work perfectly in a Windows Forms, WPF, or Console application, but it won’t work at all in … Read more

How do I start a process from C#?

As suggested by Matt Hamilton, the quick approach where you have limited control over the process, is to use the static Start method on the System.Diagnostics.Process class… using System.Diagnostics; … Process.Start(“process.exe”); The alternative is to use an instance of the Process class. This allows much more control over the process including scheduling, the type of … Read more

Process.start: how to get the output?

You can process your output synchronously or asynchronously. 1. Synchronous example static void runCommand() { Process process = new Process(); process.StartInfo.FileName = “cmd.exe”; process.StartInfo.Arguments = “/c DIR”; // Note the /c command (*) process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.Start(); //* Read the output (or the error) string output = process.StandardOutput.ReadToEnd(); Console.WriteLine(output); … Read more