Solved

How to call system commands

Posted on 2004-09-08
8
2,009 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

789 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