c# - How to get the process Id safely after process.Start()? -


when program copied many locations , started independently, error may appear:

processstartinfo startinfo = new processstartinfo(exepath); startinfo.windowstyle = processwindowstyle.hidden; startinfo.errordialog = false;  process process = new process() { startinfo = startinfo }; bool isstarted = process.start(); int processid = process.id; // failed bellow when isstarted false 

system.invalidoperationexception: no process associated object.

since starting exe files don't need useshellexecute feature. unfathomable reason useshellexecute set true default. using entails lot of complexity.

set useshellexecute false , start should return true. then, id should valid. sure dispose of process instance.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -