C# .NET - running a batch file

Asked By egg user on 29-Sep-08 01:26 AM

hi all,

i am trying to run a batch file (on remote server) from C# code (windows service). whats happening is when it tries to runs that batch file it gives a security warning, so i just wanna know how to handle that. i am using ProcessStartInfo and also i mapped that remote file server as network drive on my machine.

thanks in advance,

sachin


solution

Perry replied to egg user on 29-Sep-08 02:55 AM
Hi,

The .bat extension is not a Win32 application catagory so first of all to run from C# using ProcessStartInfo you will need to use filename as cmd.exe and arguments will be "/c your batch file". To execute it on remote machine, the application running context must have permission to execute command on remote machine. I will suggest you to use Plink utility to connect to remote machine using SSH and then run the command.

-Paresh
aakash m replied to Perry on 29-Dec-11 10:42 AM
hi paresh,

could you please help in knowing how to execute bat file at below location

\\asknet\my.bat


thanks
-aakash