473,402 Members | 2,053 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,402 software developers and data experts.

what am I doing wrong with my Process.Start?



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!
Nov 16 '05 #1
4 8400
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" <mr***@reedassociates.com> wrote in message
news:u0**************@TK2MSFTNGP12.phx.gbl...


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!

Nov 16 '05 #2
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

Nov 16 '05 #3

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

I am using:

System.Diagnostics.Process.Start("cmd.exe", "/c dir");
Nov 16 '05 #4
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
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jwayne | last post by:
I'm trying to implement a navigation bar with multiple a href classes. The following example works exactly as I want it to, but for Internet Explorer only. Firefox does not indent each link. ...
2
by: Tobias Johansson | last post by:
Hello, I'm having what I believe a security problem to execute an executable file from a windows service in windows server 2003. It works fine in WIN XP SP2 The program(the service) itself...
10
by: Tony | last post by:
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is...
3
by: Volker Jobst | last post by:
Hello, I'm opening a PDF File (e.g. "C:\test.pdf") in my windows forms vb.net application using the following command: System.Diagnostics.Process.Start("C:\test.pdf") On a machine with...
6
by: bill | last post by:
I have a VB .net 2.0 site that needs to run a dos app upon a button click. I found Shell too unreliable using parameters and so used system.diagnostic.process. simple troubleshooting...
5
by: Atara | last post by:
On Windows Vista, Process.Start() generates Win32Exception. Sample Code: Dim selfProc As String = System.Windows.Forms.Application.ExecutablePath System.Diagnostics.Process.Start(Chr(34) &...
2
by: Saya | last post by:
Hi, I am trying to develop a WebService that needs to execute some application commands on a server. I am using System.Diagnostics.Process. The reason for trying to impersonate a user is that...
7
by: Kevin Vogler | last post by:
I'm trying to programatically run an app. The command line syntax is: "C:\Program Files\WinSCP3\WinSCP3.exe" -script=myscript.txt and it works as intended. In code, I have this Dim myProc As...
5
by: sjoshi23 | last post by:
Hello I'm trying to start a remote desktop session using Process.Start but it keeps saying "File not found". The same cmd thru DOS window works fine. I used: C:\\WINDOWS\\system32\\mstsc.exe...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.