c# - Cannot run a batch file from a Windows service in Windows server 2003 OS -
i using following code run batch file c#. following code part of windows service. code works fine in windows xp when deploy windows service windows server 2003 os returns exit code 1 (failure). know missing? need give special permission windows service? service installed local system service.
processstartinfo psi = new processstartinfo(); //specify name , arguments pass command prompt psi.filename = configurationmanager.appsettings["batchfilepath"]; psi.arguments = filename; //create new process , set starting information process p = new process(); p.startinfo = psi; //set can tell when process has completed p.enableraisingevents = true; p.start(); //wait until process has completed while (!p.hasexited) { system.threading.thread.sleep(1000); } //check see exit code if (p.exitcode != 0) { logger.write("exit code" + p.exitcode); }
my next set try setting service run user you're logged in when works. way you'll know whether specific network service account that's stopping working
Comments
Post a Comment