Oinkers
Oinkers

Reputation: 15

Why does this work in ISE but not when launched from a batch file?

If I run this script in Powershell ISE it works, but when it is launched from a batch file, it does not work. The script is here(clicky). The batch file that launches this is here(clicky).

When launched from the batch file, powershell writes (0) and it does not work. When launched from ISE, powershell writes (1) and then works.

Also, I did confirm that the script is being run, but not correctly.

Thank you in advance!

Upvotes: 0

Views: 837

Answers (1)

Frode F.
Frode F.

Reputation: 54881

It may seem like you're double-quoting the path to the script. Also, Why are you using PowerShell to start another PowerShell to call the file? Try:

@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath="%ThisScriptsDirectory%\data\Start.ps1"
PowerShell -ExecutionPolicy Bypass -File %PowerShellScriptPath%

Upvotes: 1

Related Questions