Run a Powershell script independently of C# application -
this question has answer here:
- how create process outlives parent 3 answers
the aim of code is: pass integer value of seconds powershell script used tell powershell script wait , restart console application.
the problem: powershell script instance exists inside of application. means application waits until script finished when want exit application , leave script running.
powershell psexec = powershell.create(); psexec.addcommand(@powershellscriptlocation); psexec.addargument(convert.toint32(calculatetimetowait().totalseconds)); psexec.invoke();
you need :)
var psi = new processstartinfo("powershell.exe", "pathtoyourscript , args"); var process = process.start(psi); process.waitforexit();
Comments
Post a Comment