process - C# batch file execution never exits -


i trying execute batch file runs on own. trying automate deploying windows service listens folder , invokes batch file using file watcher event. here code -

void filesystemwatcher_created(object sender, filesystemeventargs e) {     serviceeventlog.writeentry(theservicename + " inside filesystemwatcher_created() - ");     if (e.name.trim().toupper().contains("fu4dgf_trades"))     {         try         {             utilities.sendemail("iamldnsmtp", 25, "desmond.quilty@investecmail.com", "iamitdevelopmentservices@investecmail.com", "ben.howard@investecmail.com", "prasad.matkar@investecmail.com", "statpro batchfile execution started ", "");             int exitcode;             //  processstartinfo processinfo;             serviceeventlog.writeentry(theservicename + " before creation of instance of batch process - ");             process process = new process();             process.startinfo.filename = @"c:\program files (x86)\statpro suite\monthlyupload.bat";             process.startinfo.redirectstandardoutput = false;             process.startinfo.redirectstandarderror = false;             process.startinfo.createnowindow = false;             process.startinfo.workingdirectory = @"c:\program files (x86)\statpro suite";             process.startinfo.useshellexecute = false;             serviceeventlog.writeentry(theservicename + " before start  of batch process - ");             process.start();             serviceeventlog.writeentry(theservicename + " after start  of batch process - ");             process.waitforexit();             //while (!process.hasexited)             //{             //    system.threading.thread.sleep(100);             //}              serviceeventlog.writeentry(theservicename + " after process.close - ");             system.environment.exitcode = process.exitcode;         } 

i can see event log goes far logging - before start of batch process. presumably after process starts invoking process.start() nothing happens. nothing in event log, service still running i.e. not crashed. no errors. can see task manager invoke exe supposed invoke via batch file exe remains in memory constant memory , 0 cpu usage suggesting exe not doing anything. if run batch file manually works fine. idea going wrong?

you disabled useshellexecute. means you can't use shell execute file. bat files not executables, shell scripts.

since you're not redirecting standard i/o anyway, enable useshellexecute , should fine.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -