Run a Powershell script independently of C# application -


this question has answer here:

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

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -