PC Review


Reply
Thread Tools Rate Thread

what am I doing wrong with my Process.Start?

 
 
Mark Reed
Guest
Posts: n/a
 
      11th Feb 2005


I am trying to have a button that brings up the cmd prompt and then does
a DIR listing.

I am using:

private void button2_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("cmd.exe","dir");
}

It does everything except the dir.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Richard A. Lowe
Guest
Posts: n/a
 
      12th Feb 2005
Should be:

..Start(@"cmd.exe", "/C ""dir""");

or something similar (didn't test this exact code). Just running cmd.exe
dir (try it on the command line) doesn't work - cmd.exe /C "dir" DOES work,
so you have to pass the parameters like that.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Mark Reed" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> I am trying to have a button that brings up the cmd prompt and then does
> a DIR listing.
>
> I am using:
>
> private void button2_Click(object sender, System.EventArgs e)
> {
> System.Diagnostics.Process.Start("cmd.exe","dir");
> }
>
> It does everything except the dir.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Mark Reed
Guest
Posts: n/a
 
      13th Feb 2005
I must be doing something wrong. I have:

System.Diagnostics.Process.Start(@"cmd.exe", "/C","dir");

but get:
C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects
\WindowsApplication6\Form1.cs(90): No overload for method 'Start' takes
'3' arguments

Being a newbie, Im stuck on this.


M. Reed

 
Reply With Quote
 
Mark Reed
Guest
Posts: n/a
 
      13th Feb 2005

I have it working somewhat...but the console window closes right away.

I am using:

System.Diagnostics.Process.Start("cmd.exe", "/c dir");
 
Reply With Quote
 
Mark Reed
Guest
Posts: n/a
 
      13th Feb 2005
GOT IT!

Sorry for the threaded posts as I worked thru it...

System.Diagnostics.Process.Start("cmd.exe", "/k dir");
is what I needed... wrong flag earlier...has /c and needed /k
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? Daniel Microsoft Windows 2000 Networking 1 13th Apr 2006 08:58 AM
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? Daniel Microsoft Dot NET Framework 1 13th Apr 2006 04:56 AM
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? Daniel Microsoft Windows 2000 0 12th Apr 2006 11:47 PM
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? Daniel Microsoft C# .NET 0 12th Apr 2006 11:47 PM
what permissions does a windows service need to execute another process? System.Diagnostics.Process process = System.Diagnostics.Process.Start(info); just local administrator? any specific permitions? Daniel Microsoft Dot NET 0 12th Apr 2006 11:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:31 AM.