diff --git a/scripts/watch-public-runtime-task.vbs b/scripts/watch-public-runtime-task.vbs index 9c59687..1b7a0e3 100644 --- a/scripts/watch-public-runtime-task.vbs +++ b/scripts/watch-public-runtime-task.vbs @@ -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 -StableSourceRoot ..." @@ -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