473,385 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with System.Diagnostics.Process class

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
2 5014
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: gmesmer | last post by:
Hello I have created an assembly to print a pdf document and I wrote some unit tests and everything works from within nuint and cruisecontrol.net. ( I am using C#) Next I have to put together a...
0
by: CMG | last post by:
I am trying to run gocr from my program, and use the output. I have done this with success befor, with a workaround command line tool.: Private irfanview As String = "C:\program...
0
by: Robert Björn | last post by:
I'm trying to process a MemoryStream of XML data, which at any point in time may have incomplete fragments (because data arrives from a socket). If I process data until XmlTextReader.Read()...
2
by: Jesper Stocholm | last post by:
I have created a simple service which just copies a fil to a new file with a new name on certain intervals (the service implements a timer). I have no problems installing the service and the...
4
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
1
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular I...
0
by: CMG | last post by:
I am trying to run gocr from my program, and use the output. I have done this with success befor, with a workaround command line tool.: Private irfanview As String = "C:\program...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.