워치독 런처가 powershell.exe를 전체 경로로 호출하도록 고정
PATH 탐색에 기대면 작업 스케줄러 컨텍스트의 PATH가 로그온 세션과 다를 때 powershell.exe를 찾지 못하고, 그 경우 워치독은 로그 한 줄 없이 실패만 남긴다. %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe로 고정한다.
This commit is contained in:
parent
5cb530e153
commit
0c56f1857a
1 changed files with 6 additions and 3 deletions
|
|
@ -10,8 +10,9 @@
|
|||
' 경로를 하드코딩하지 않으므로 stable source root 가 바뀌어도 이 파일은 그대로 쓴다.
|
||||
Option Explicit
|
||||
|
||||
Dim objShell, args, i, arg, cmd, exitCode, dryRun
|
||||
Dim objShell, args, i, arg, cmd, exitCode, dryRun, psExe
|
||||
|
||||
Set objShell = CreateObject("WScript.Shell")
|
||||
Set args = WScript.Arguments
|
||||
If args.Count = 0 Then
|
||||
WScript.Echo "usage: watch-public-runtime-task.vbs -File <watch-public-runtime.ps1> -StableSourceRoot <root> ..."
|
||||
|
|
@ -22,8 +23,11 @@ If LCase(args(0)) = "syntax-only" Then
|
|||
WScript.Quit 0
|
||||
End If
|
||||
|
||||
' PATH 탐색에 기대지 않는다. 작업 스케줄러 컨텍스트의 PATH 는 로그온 세션과 다를 수
|
||||
' 있고, 그때 powershell.exe 를 못 찾으면 워치독은 로그 한 줄 없이 실패만 남긴다.
|
||||
dryRun = False
|
||||
cmd = "powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden"
|
||||
psExe = objShell.ExpandEnvironmentStrings("%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe")
|
||||
cmd = """" & psExe & """ -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden"
|
||||
For i = 0 To args.Count - 1
|
||||
arg = args(i)
|
||||
If i = 0 And LCase(arg) = "print-command" Then
|
||||
|
|
@ -40,6 +44,5 @@ If dryRun Then
|
|||
WScript.Quit 0
|
||||
End If
|
||||
|
||||
Set objShell = CreateObject("WScript.Shell")
|
||||
exitCode = objShell.Run(cmd, 0, True)
|
||||
WScript.Quit exitCode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue