2
Answers

Spawning a legacy app in CMD window in C#

Tom Ratcliffe

Tom Ratcliffe

12y
1.5k
1
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.

Answers (2)
Next Recommended Forum