Execute batch file from win service

Posted by Jpchoudhari under C# on 7/18/2011 | Points: 10 | Views : 3499 | Status : [Member] | Replies : 1
Hi,

I have created a service to execute a batch file from it. The service is working fine on my Development Machine (XP) but not working on Production Server (Windows Server 2003
R2).

Code I am using to execute batch file is

 System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = strBatchPath;
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();


I have debug the service on server; Code is not giving any type of error but anyway the .bat file is also not run.
any suggestions.

Kind Regards,
Jay



Responses

Posted by: Naraayanan on: 12/29/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Check with path of batch file .it is my guess.. comment that 3 lines(3,4,5) and create a code with in try catch statement


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Jpchoudhari, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response