Unable to start program outside Windows folder

265 views Asked by At

I'm trying to control an external program that I call inside PowerShell and if this program takes more than 10s, for example, I want to terminate it. How can I accomplish that?

I have searched, but what I found was the following code. I can use this code to call calc.exe for example, and terminate it after a specific amount of time, but I can't call another program that is not from 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()
1

There are 1 answers

2
jimmy On

A very likely problem is that the program you are trying to run is an x86 application and you are trying to run it from powershell x64. This will not work and as far as I remember powershell will not even tell you why.

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