'Running an exe in PowerShell script
I have a PowerShell script that downloads an exe and then runs it.
The download part of the code works fine but the issue is when the script goes to run the exe.
Invoke-WebRequest -Uri "https://...redacted..." -OutFile "C:\application.exe"
I'm using Start-Process -Wait -FilePath "C:\application.exe" -ArgumentList "/conf conf.xml
The error that I get is Suggestion [3,General]: The command application.exe was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\application.exe". See "get-help about_Command_Precedence" for more details.
I found this post on the topic but how would I implement it in my line of code?
If I'm in PowerShell and run .\application.exe /conf conf.xml it runs with no errors. I just get the errors when I run the .ps1 script.
Solution 1:[1]
@MisterSmith thank you that resolved the issue.
Start-Process -WorkingDirectory "C:\folder" -Wait -FilePath "C:\folder\application.exe" - ArgumentList "/conf conf.xml"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 330sysadmin |
