Hide Windows scheduler bot execution

This commit is contained in:
whdwo
2026-07-02 16:06:14 +09:00
parent c43163629d
commit 80457fe6c4
5 changed files with 40 additions and 4 deletions
+4 -2
View File
@@ -25,7 +25,7 @@ function Register-StockTask {
$Trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek $Weekdays -At $Time
$Action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NonInteractive -ExecutionPolicy Bypass -File `"$Project\scripts\$Script`"" `
-Argument "-NoProfile -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -File `"$Project\scripts\$Script`"" `
-WorkingDirectory $Project
$Settings = New-ScheduledTaskSettingsSet `
-ExecutionTimeLimit (New-TimeSpan -Minutes $LimitMinutes) `
@@ -34,6 +34,7 @@ function Register-StockTask {
-DontStopIfGoingOnBatteries `
-RunOnlyIfNetworkAvailable:$false
$Settings.DisallowStartIfOnBatteries = $false
$Settings.Hidden = $true
Register-ScheduledTask `
-TaskName $Name `
@@ -49,7 +50,7 @@ function Register-StockTask {
function Register-WatchdogTask {
$ScriptPath = Join-Path $Project "scripts\run_watchdog.ps1"
$Command = 'schtasks /Create /TN "\StockBot\StockBot_Watchdog" /TR "\"powershell.exe\" -NonInteractive -ExecutionPolicy Bypass -File \"' + $ScriptPath + '\"" /SC WEEKLY /D MON,TUE,WED,THU,FRI /ST 09:00 /RI 5 /DU 06:05 /F'
$Command = 'schtasks /Create /TN "\StockBot\StockBot_Watchdog" /TR "\"powershell.exe\" -NoProfile -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -File \"' + $ScriptPath + '\"" /SC WEEKLY /D MON,TUE,WED,THU,FRI /ST 09:00 /RI 5 /DU 06:05 /F'
cmd.exe /c $Command | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "StockBot_Watchdog registration failed"
@@ -60,6 +61,7 @@ function Register-WatchdogTask {
$Task.Settings.WakeToRun = $true
$Task.Settings.DisallowStartIfOnBatteries = $false
$Task.Settings.StopIfGoingOnBatteries = $false
$Task.Settings.Hidden = $true
Set-ScheduledTask -TaskName "StockBot_Watchdog" -TaskPath $TaskPath -Settings $Task.Settings | Out-Null
Write-Host "[OK] StockBot_Watchdog registered weekdays at 09:00-15:05 every 5 minutes" -ForegroundColor Green