1
votes

If I paste this into Powershell blue window it runs fine and launches the program

Start-Process “C:\Program Files (x86)\Engine Pro\engine.exe” -ArgumentList "#21#”;

but if I try to run the same command in a script, run.ps1 script, that launches from a scheduled task in Windows, it does nothing

PowerShell.exe -windowstyle hidden -NoProfile -ExecutionPolicy Bypass C:\run.ps1

Does it have something to do with the -ExecutionPolicy Bypass? Do I have to have an Execution policy in the script as well? I really don't know what that is. I know what -windowstyle hidden is but -NoProfile -ExecutionPolicy Bypass I'm not sure why that is there, just found it on another page, but it's all working except for the program launching from within the script.

Thank you.

1
Your command uses Unicode (non-ASCII) double quotation marks; unless you save your *.ps1 files as UTF-8 with BOM (or as UTF-16LE), PowerShell will misinterpret it. - mklement0
Depending on your PowerShell Version (below 6/core) the default is -Command not -File, so you may need to use PowerShell.exe -windowstyle hidden -NoProfile -ExecutionPolicy Bypass -File C:\run.ps1 - user6811411
The whole script works with the " " on everything, but when I try to launch a program from within the scritp it just does noting. Im using " " and editing the file with coding program ATOM 1.33.1 x64. Adding -File did nothing. I thought it might be BitDefender but I switched that off and stiff the program is not launching. I tried launching notepad.exe from the script and that doesn't launch either. Not sure what's happening. - Kurt Lane
Stupid me, It was the & symbol. Ive seen it on hundreds of threads already. & Start-Process "C:\Program Files (x86)\Engine Pro\engine.exe" -ArgumentList "#21#"; worked, Took a while it figure it out. Thanks everyone - Kurt Lane

1 Answers

0
votes
& Start-Process "C:\Program Files (x86)\Engine Pro\engine.exe" -ArgumentList "#21#";