Failed to run program outside of Windows folder

I am trying to control an external program that I am calling inside PowerShell, and if this program takes more than 10 seconds, for example, I want to terminate it. How can i do this?

I searched, but I found the following code. I can use this code to call calc.exe

, for example, and terminate it after a certain time, but I cannot name another program that does not belong to the system32 or Windows folder. Why?

$ps = New-Object diagnostics.processstartinfo
$ps.FileName='c:\folder\program.exe'
$p = [System.Diagnostics.Process]::Start($ps)
$p.WaitForExit(10000)
$p.Kill()

      

+3


source to share


1 answer


Most likely the problem is that the program you are trying to run is an x86 application and you are trying to run it from powershell x64. It won't work, and as far as I remember, PowerShell won't even tell you why.



Instead, you need to run the x86 version. https://technet.microsoft.com/en-us/library/hh847733.aspx

0


source







All Articles