0

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!

Oinkers
  • 15
  • 3

1 Answers1

1

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%
Frode F.
  • 52,376
  • 9
  • 98
  • 114
  • I am using this as a batch file, which then calls the Powershell file. And this does the same thing, but in a batch window rather than a powershell window. – Oinkers Jul 26 '14 at 22:08
  • And why is that a bad thing? The only difference is that it uses the cmd-window(btw a powershell window is the same console only with a blue background) until the script is done. If you want to run it in a separate window, use `start /wait PowerShell -ExecutionPolicy Bypass -File %PowerShellScriptPath%`. `PowerShell.exe` is slow to start and uses lots of resources, so you would want to create as few processes as possible. – Frode F. Jul 26 '14 at 22:15
  • Details? Are there any errors? if so, include them in your question. – Frode F. Jul 27 '14 at 19:25