Solved

How to call system commands

Posted on 2004-09-08
8
2,008 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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