| 0 down vote favorite | I need to run a legacy app that is run from a cmd window using the Process class. ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C \"C:\\UTDSys\\UTD2TCM.exe –r " + Parameters.Candidate + "\""; startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close. using (Process exeProcess = Process.Start(startInfo)) { exeProcess.WaitForExit(); } } catch (Exception e) { string sMsg = "Error copying the files to " + Parameters.FullPath + "."; HandleErrorMsg(e, sMsg); return; } The process My2Com.exe should run in the background, however, I consistantly get the message that a file, used when run from the cmd line with different flags, is missing. If I run the command as indicated in a cmd window, C:\MySys\My2Com.exe –r FullyQualPath, it works as expected. I have tried several different ways to set up the Process class without success. Any suggestions would be appreciated. Thank you, Tom R. |
Loading
Tom RatcliffePosted Aug 16, 2012, 9:05 AM
startInfo.FileName = "C:\\UTDSys\\UTD2TCM.exe";
startInfo.Arguments = "-r " + Parameters.FilePath.ToString();
or
startInfo.FileName = "C:\\UTDSys\\UTD2TCM.exe";
startInfo.Arguments = string.Format("-r {0}", Parameters.FilePath);
VulpesPosted Aug 15, 2012, 5:59 PM
Otherwise, I'd try: