为什么这在ISE中有效,而在从批处理文件启动时却无效?

时间:2014-07-26 17:13:03

标签: batch-file powershell powershell-ise

如果我在Powershell ISE中运行此脚本,它可以工作,但是当它从批处理文件启动时,它不起作用。该脚本为here(clicky)。启动它的批处理文件是here(clicky)

从批处理文件启动时,powershell写入(0)并且它不起作用。当从ISE启动时,powershell写入(1)然后工作。

另外,我确实确认脚本正在运行,但不正确。

提前谢谢!

1 个答案:

答案 0 :(得分:1)

您可能看起来像是在引用脚本的路径。另外,为什么使用PowerShell启动另一个PowerShell来调用该文件?尝试:

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