By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

Problems with System.Diagnostics.Process class

P: n/a
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 follow 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);
}
}
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello Joey,

Why do you have to execute cmd.exe first? Process class allows you to execute
command already, so you just have to execute strCmdLine with Process.
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 follow 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

--------------

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);
}
}

Nov 16 '05 #2

P: n/a
Looks like you're trying to build a GUI front end for stsadm. Perhaps
this might interest you:

http://www.microsoft.com/sharepoint/...tail.asp?a=443

Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - blog

Joey Mack <jw***@sbcglobal.net> wrote in message news:<WT*******************@newssvr19.news.prodigy .com>...
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 follow 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);
}
}

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.