Link to home
Create AccountLog in
Avatar of kunal_chopra28
kunal_chopra28

asked on

Shell Commands using Process Info in System.Diagnostics

Hey experts,

I'm writing a simple program in C# to loop through an XML file and execute commands one after the other on a machine. The primary purpose of this application is to automated a number of deployment steps.

I'm using ProcessInfo and Process in the .NET library and using C# as the language.

Problem:
-------------

I'm unable to execute DOS/Shell commands using ProcessInfo object. Simple exe's, bat's etc work, but when trying o execute a system specific shell command doesn't work.

Examples:
---------------

As an example:

1. Install.exe C:\Program Files\..... works
2. del c:\Program Files\....\abcd.txt doesn't work

So my question is:

How do you execute such DOS commands like del, dir etc using the System.Diagnostics classes in .NET.

I'm open to other namespaces as well in .NET as well as other free tools to get the job done.

Avatar of rockiroads
rockiroads
Flag of United States of America image

if(System.IO.File.Exists("c:\Program Files\....\abcd.txt"))
System.IO.File.Delete("c:\Program Files\....\abcd.txt");
ASKER CERTIFIED SOLUTION
Avatar of andr_gin
andr_gin

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of kunal_chopra28
kunal_chopra28

ASKER

Thank you for the comments and answer