CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Apr 2006
    Location
    Rhode Island
    Posts
    32

    [RESOLVED] Run cmdline code with C#

    I'm trying to eliminate our dependence on batch files for compiling our many projects. I am forced to use a huge batch file to create our installation and am just tired of all my co-workers' questions about how to compile certain projects. So I'm trying to create an application in C# that will dynamically compile, register, delete, etc the projects that a specific project.

    The problem I'm having is that I cannot execute commandline code from C#. I used the examples that I've found on MSDN, CodeGuru, etc. and below is what I've come up with. I've used the code from the batch file that is supposed to usable by commandline. But when I run the code below all I get is a cmd window that points to the debug folder of the project itself (not the one I need compiled).

    Here's most of my code, or at least the portion that will execute the commandline:
    Code:
    //--- create process member
    System.Diagnostics.Process compilerProcess;
    compilerProcess = new System.Diagnostics.Process();
    compilerProcess.EnableRaisingEvents = false;
    compilerProcess.StartInfo.FileName = @"C:\\windows\\system32\\CMD.exe";
    compilerProcess.StartInfo.Arguments = "C:\\Program Files\\Microsoft Visual Studio\\COMMON\\msdev98\\Bin\\msdev.exe c:\\cql\\source\\mainline\\souce\\create\\cql.dsw /MAKE cql_ii - Win32 Release";
    compilerProcess.StartInfo.UseShellExecute = false;
    compilerProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    compilerProcess.StartInfo.CreateNoWindow = true;
    compilerProcess.StartInfo.RedirectStandardOutput = true;          
    compilerProcess.Start();
    compilerProcess.WaitForExit();
    rtfOutput.Text = compilerProcess.StandardOutput.ReadToEnd().ToString();
    compilerProcess.Close();
    Any help in this is appreciated...
    Last edited by DemonPiggies; February 4th, 2011 at 12:45 PM. Reason: Forgot code tags, sorry...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured