2
我在目錄c:\scripts\
中有以下腳本。在PowerShell控制檯和ISE中源代碼腳本目錄中的文件?
# . c:\scripts\anotherScript.ps1
function GetScriptRoot { Split-Path $script:MyInvocation.MyCommand.Path }
. "$(GetScriptroot)\anotherScript.ps1"
但是,它會在ISE中引發錯誤。這是一種可以在控制檯和ISE中使用的方式嗎?我試圖不使用完整的絕對路徑。
好吧,也許我不得不使用ISE全路徑。如何檢測腳本在ISE/Console中運行? – ca9163d9 2012-01-14 00:01:44
@NickW檢查我的更新答案。 – 2012-01-14 00:26:09