Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Diagnostics.Process Problems

Status
Not open for further replies.

jwm68

Programmer
Nov 30, 2004
3
US
Greetings. I am trying to use the System.Diagnostics.Process class to perform some actions through the Windows command line. The applicable code appears below. The code builds the command fine, and will open the command line in the proper working directory, but will not send the follow-up command to the command line.

The code also catches no errors.

Any assistance would be greatly appreciated.

Thanks.

Joe

Code:
private void deleteButton_Click(object sender, System.EventArgs e)
{
    try
    {
        sysProcess = new System.Diagnostics.Process();
        sysProcess.StartInfo.FileName = "cmd.exe";
        sysProcess.StartInfo.UseShellExecute = true;
        sysProcess.StartInfo.WorkingDirectory = "C:\\Program Files\\Common Files\\Microsoft Shared\\web server extensions\\60\\bin\\";
        string strCmdLine;
        string shortCab;
        shortCab = cabName.Text.Substring(cabName.Text.LastIndexOf("\\")+1);
        //Build follow-up command
        strCmdLine = "stsadm.exe -o deletewppack -name " + shortCab;
        Debug.Write("strCmdLine = " + strCmdLine);
        sysProcess.StartInfo.Arguments = strCmdLine;
        sysProcess.Start();
        sysProcess.Close();       
    }
    catch (Exception ex)
    {
        Debug.Write("Exception: " + ex);
    }
}
 
You can write your commands via System.IO streamwriter objects to a .cmd file, and then use the Process class to run it.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top