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.
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.
try the example given here http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ShellCommandsInCS12032005042031AM/ShellCommandsInCS.aspx
if(System.IO.File.Exists(" c:\Program Files\....\abcd.txt"))
System.IO.File.Delete("c:\ Program Files\....\abcd.txt");
System.IO.File.Delete("c:\
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the comments and answer