powershell.exe
does not assume that a parameter is automatically a file to execute; you need to identify all parameters. Use the -File
switch
proc = subprocess.Popen(["powershell.exe", "-File", r"F:\FOLDER\FOLDER OK\myfile.ps1"])
The r
in r"..."
(for raw) turns off escape-sequence processing so that \
can be used without escaping.
See PowerShell Command Line Help at Microsoft Docs.
PowerShell[.exe]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>]
[-File <FilePath> [<Args>]]
[-InputFormat {Text | XML}]
[-Mta]
[-NoExit]
[-NoLogo]
[-NonInteractive]
[-NoProfile]
[-OutputFormat {Text | XML}]
[-PSConsoleFile <FilePath> | -Version <PowerShell version>]
[-Sta]
[-WindowStyle <style>]