워치독 런처가 powershell.exe를 전체 경로로 호출하도록 고정

PATH 탐색에 기대면 작업 스케줄러 컨텍스트의 PATH가 로그온 세션과 다를 때
powershell.exe를 찾지 못하고, 그 경우 워치독은 로그 한 줄 없이 실패만 남긴다.
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe로 고정한다.
This commit is contained in:
Yun Chan 2026-08-12 21:28:58 +09:00
parent 5cb530e153
commit 0c56f1857a

View file

@ -10,8 +10,9 @@
' 경로를 하드코딩하지 않으므로 stable source root 가 바뀌어도 이 파일은 그대로 쓴다. ' 경로를 하드코딩하지 않으므로 stable source root 가 바뀌어도 이 파일은 그대로 쓴다.
Option Explicit 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 Set args = WScript.Arguments
If args.Count = 0 Then If args.Count = 0 Then
WScript.Echo "usage: watch-public-runtime-task.vbs -File <watch-public-runtime.ps1> -StableSourceRoot <root> ..." 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 WScript.Quit 0
End If End If
' PATH 탐색에 기대지 않는다. 작업 스케줄러 컨텍스트의 PATH 는 로그온 세션과 다를 수
' 있고, 그때 powershell.exe 를 못 찾으면 워치독은 로그 한 줄 없이 실패만 남긴다.
dryRun = False 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 For i = 0 To args.Count - 1
arg = args(i) arg = args(i)
If i = 0 And LCase(arg) = "print-command" Then If i = 0 And LCase(arg) = "print-command" Then
@ -40,6 +44,5 @@ If dryRun Then
WScript.Quit 0 WScript.Quit 0
End If End If
Set objShell = CreateObject("WScript.Shell")
exitCode = objShell.Run(cmd, 0, True) exitCode = objShell.Run(cmd, 0, True)
WScript.Quit exitCode WScript.Quit exitCode