Skip to content

Check tasksched fixes misc#393

Merged
sni merged 5 commits into
mainfrom
check-tasksched-fixes-misc
Jun 22, 2026
Merged

Check tasksched fixes misc#393
sni merged 5 commits into
mainfrom
check-tasksched-fixes-misc

Conversation

@inqrphl

@inqrphl inqrphl commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Fix problem where calling snclient run check_tasksched caused the windows terminal / powershell to hide or close. This was due to hideWindow being true without using the task creation option NO_WINDOW.

Use blacklists instead of whitelists when specifying title and folder arguments. These blacklists are taken from task scheduler directly. This is a better approach, and works with CJK characters as well, windows does allow them in task scheduler paths.

This works alongside earlier changes to powershell command runner, which does not accept parameter definitions that contain single or double quoutes. While they are allowed in the task folder paths, they are a security issue if let through.

Rewrite the scheduling script using deepseek-v4-pro. Instead of using Get-ScheduleTasks which imports a module, use the Schedule.Service COM api. This was required due to some systems blocking/delaying powershell module imports up to 20 seconds.

This delay was reproducible in the affected machines, and happened on each run if powershell.exe was started separately to run the script. When the script was called from an existing powershell terminal, it did not happen. This was most likely caused by antivirus software, which selectively checks the imported modules, but not fully confirmed.

inqrphl added 5 commits June 19, 2026 15:02
call Get-ScheduledTaskInfo once using $tasks array, and save its results into a map. this is faster than calling it for each element in $tasks

use a typed list for saving results. adding to this list is faster than calling += on a default array repedately
hideWindow: true was set when creating a new powershell process.
this process inherited the parents console.

when running snclient on windows terminal, it would minimize it.

when running snclient on conhost/powershell, it would close it. I am unsure why.

when running through a vscode terminal, it would be uneffected. I am still unsure why.

adding windows.CREATE_NO_WINDOW, stops the inheritance of the console window and these side effects. stdout/stderr piping still works.
the blacklist is taken from the error you get when creating a new task with illegal characters on task scheduler
…Get-ScheduledTask in the scheduled task discovery script

Get-ScheduledTask would import the module, and importing a module can be intercepted by antivirus. This took around 20 seconds in each call on some machines.

Do away with the module imports completely, use the deeper APIs of COM objects.
@sni sni merged commit 97d7087 into main Jun 22, 2026
139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants