Solved

How to call system commands

Posted on 2004-09-08
8
2,005 Views
Last Modified: 2010-04-15
hello/

how do i call system commands such as 'dir', 'cd' etc

thanks / p
0
Comment
Question by:pipe
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 100 total points
ID: 12007919
Use Process.Start() in system.diagnostics ... in order to run such commands you issue cmd /C command ...

Process.Start("cmd.exe", "/C dir"); (or use the startinfo overload) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic2.asp
0
 
LVL 3

Expert Comment

by:sohilm
ID: 12007931
What are you trying to accomplish? Are you trying to modify files, or display files on the screen?
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12009924
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12009958
gregasm isnt

Process.Start("cmd.exe", "/C dir")
and
Shell("cmd.exe","/C dir")

nearly the same thing ? :)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12009961
in fact shell calls Process.Start :P
0
 
LVL 8

Expert Comment

by:gregasm
ID: 12010014
shell("explorer.exe ""c:\my music\""")

something like that. right on.
0
 

Author Comment

by:pipe
ID: 12010237
ill look into this tonight. i am making my own command prompt and i was just gonna issue the commands (like suggested above) and return the results to my custom command prompt.
0
 
LVL 3

Expert Comment

by:sohilm
ID: 12010404
well I suggest using the system.io.directoryinfo and system.io.fileinfo to get info and do some basic tasks. This way you have more control on what to show on the screen.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
send mail from app.net 8 28
Problem with SqlConnection 5 110
optimize  c# code 7 48
Trouble with References... 5 22
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now