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.

C#Windows BatchProgramming

Avatar of undefined
Last Comment
kunal_chopra28

8/22/2022 - Mon
rockiroads

Gururaj Badam

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

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
kunal_chopra28

ASKER
Thank you for the comments and answer
Your help has saved me hundreds of hours of internet surfing.
fblack61