- src/dist 산출물 분리 원칙 정리(.gitignore, .gitattributes) - 루트 및 주요 폴더(config/scripts/prompts/tests/src, 런타임 폴더 5종)에 안내용 README.md 추가 - CHANGELOG.md, LICENSE, docs/ops/05-release-and-versioning.md 추가 - docs/README.md 문서 지도 갱신
7112 lines
No EOL
405 KiB
Markdown
7112 lines
No EOL
405 KiB
Markdown
# RAW RESEARCH DUMP — agent-a99bc957be6fc45cc
|
||
|
||
## ORIGINAL TASK PROMPT
|
||
|
||
오늘 날짜는 2026-09-02 이다. 너는 리서치 에이전트다. 반드시 먼저 ToolSearch 로 "select:WebSearch,WebFetch" 를 로드하고, WebSearch 로 최소 8회 이상 다양한 한국어/영어 질의를 던지고, 핵심 출처 페이지는 WebFetch 로 실제 열어 내용을 확인하라. 실제로 열어 확인한 항목만 verified_by_fetch=true 로 표시하라. 존재를 확인하지 못한 URL, GitHub 저장소, 논문, CLI 플래그는 절대 지어내지 말고 confidence='low' 로 표시하거나 제외하라. 한국 사이트(nedrug.mfds.go.kr, data.go.kr 등)는 WebFetch 가 실패할 수 있으니 실패하면 그 사실을 open_questions 에 적어라. 결과의 summary/detail/recommendations 는 한국어로 쓰되 고유명사·코드·플래그는 원문 유지. 코드 스니펫은 실제 동작 가능한 수준으로 구체적으로 작성하라. 최종 출력은 StructuredOutput 스키마에 맞춰라.
|
||
|
||
프로젝트 맥락: Windows 11 PC 에서 매일 06:00 에 한국 식약처 원료의약품 등록(DMF) 공고/현황을 크롤링하여 신규/변경/취하 건을 탐지하고, 탭(시트)별로 연동된 보기 좋은 xlsx 리포트를 생성한다. 크롤링·요약 일부를 AI 에이전트 CLI(Claude Code 의 'claude -p' headless 모드 등)로 non-interactive 하게 돌리고, 재부팅 후에도 자동 복구되는 서비스/스케줄러로 운영하며, 서비스가 죽으면 Windows 알림으로 복구 안내를 띄운다.
|
||
|
||
[축 8: Windows 에서 매일 06:00 headless 크롤링을 재부팅 후에도 자동으로 돌리고, 죽으면 알림 띄우기]
|
||
조사 항목 (Microsoft Learn 공식 문서 WebFetch 로 확인):
|
||
1) Windows 작업 스케줄러(Task Scheduler): 매일 06:00 트리거 + '시스템 시작 시' 트리거 병행, '사용자의 로그온 여부에 관계없이 실행'(S4U vs 암호 저장), '가장 높은 수준의 권한으로 실행', '예약된 시작 시간을 놓친 경우 가능한 한 빨리 작업 시작'(StartWhenAvailable), '작업이 실패하면 다시 시작 간격/횟수'(RestartCount/RestartInterval), '작업 실행을 위해 절전 모드 해제'(WakeToRun), AC 전원 조건 해제, 실행 시간 제한(ExecutionTimeLimit), 다중 인스턴스 정책, 작업 기록(History) 활성화. PowerShell Register-ScheduledTask / New-ScheduledTaskTrigger / New-ScheduledTaskSettingsSet 실제 스크립트와 schtasks.exe XML 예시.
|
||
2) Windows 서비스화: NSSM, WinSW, pywin32(win32serviceutil), sc.exe failure 복구 옵션(sc failure <svc> reset= 86400 actions= restart/60000/restart/60000/restart/60000), 서비스에서 Playwright/Chromium headless 실행 시 Session 0 격리 이슈와 해결, 서비스 vs 스케줄 작업 중 이 프로젝트에 맞는 선택 기준(하루 1회 배치엔 스케줄 작업 + 상주 워치독 권장?).
|
||
3) 워치독/헬스체크: 성공 시 heartbeat 파일/레지스트리/파일 타임스탬프 갱신 → 별도 워치독 작업이 07:00 에 확인하여 미갱신이면 알림, healthchecks.io / Uptime Kuma 로 dead-man switch, 이벤트 로그 기록(Write-EventLog / New-EventLog) 과 이벤트 기반 트리거 작업.
|
||
4) Windows 알림: BurntToast(PowerShell 모듈) New-BurntToastNotification 버튼·프로토콜 액션, Python win11toast / winotify / plyer / windows-toasts 비교, 토스트가 안 뜨는 조건(집중 모드/Focus Assist, 서비스 세션 0, 로그온 전) 과 대안(msg.exe, 이메일, 슬랙/디스코드/텔레그램 웹훅), 알림 문구에 담을 복구 안내(무엇이 실패했는지, 로그 경로, 재실행 명령, 담당자).
|
||
5) 재부팅 관련: 자동 로그온(Autologon/netplwiz) 필요 여부, BitLocker·PIN 과의 충돌, 'Fast Startup' 과 예약 작업, Windows Update 재부팅 예약과 06:00 충돌 회피, 시간대/DST, 절전·최대 절전 설정(powercfg), 부팅 후 네트워크 준비 대기(Delay task for 1~2 min, 네트워크 프로필 조건).
|
||
6) WSL2 에서 cron/systemd 로 돌리는 옵션과 한계(WSL 자동 시작 필요, Task Scheduler 로 wsl.exe 실행), Docker Desktop 컨테이너 restart=always 옵션.
|
||
7) 로그 관리: 로테이션, 실행 ID, 시작/종료/건수 기록, 실패 스크린샷 저장.
|
||
실제 동작하는 PowerShell 스크립트(작업 등록, 워치독, 토스트 알림)를 코드 스니펫으로 제공하라.
|
||
|
||
dimension 필드에는 "windows-scheduling-resilience" 를 넣어라.
|
||
|
||
|
||
## [SEARCH #1] New-ScheduledTaskSettingsSet StartWhenAvailable RestartCount RestartInterval WakeToRun ExecutionTimeLimit MultipleInstances site:learn.microsoft.com
|
||
|
||
Web search results for query: "New-ScheduledTaskSettingsSet StartWhenAvailable RestartCount RestartInterval WakeToRun ExecutionTimeLimit MultipleInstances site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"New-ScheduledTaskSettingsSet (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps"},{"title":"Run a script as hidden task scheduler with powershell | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/msdn-technet-forums/d6701df5-db2f-42e5-a790-ce2fc39f853b"},{"title":"Task Scheduler Configuration - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/3310309/task-scheduler-configuration"},{"title":"Task Scheduler Error - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/2730255/task-scheduler-error?page=2"},{"title":"Can't register sheduled task with managed service account - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/607773/cant-register-sheduled-task-with-managed-service-a?orderby=newest%2Chelpful&orderBy=Helpful"},{"title":"Windows Task Scheduler Error (one or more of the specified arguments are not valid) - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/2820575/windows-task-scheduler-error-(one-or-more-of-the-s"},{"title":"New-ScheduledTask (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtask?view=windowsserver2025-ps"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/it-it/previous-versions/windows/powershell-scripting/jj649824(v=wps.620)"}]
|
||
|
||
I found the search results for the `New-ScheduledTaskSettingsSet` PowerShell cmdlet on Microsoft Learn. Here's what I found:
|
||
|
||
The New-ScheduledTaskSettingsSet cmdlet creates an object that contains scheduled task settings, and supports parameters including -StartWhenAvailable, -WakeToRun, -ExecutionTimeLimit, -MultipleInstances, -RestartCount, and -RestartInterval.
|
||
|
||
This cmdlet is used to configure options to manage the behavior of the task upon completion, to manage the behavior of the task if a problem occurs, or to manage the behavior of the task if an instance of the task is already running.
|
||
|
||
The primary reference documentation is available at: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #2] Register-ScheduledTask New-ScheduledTaskPrincipal LogonType S4U Password RunLevel Highest PowerShell
|
||
|
||
Web search results for query: "Register-ScheduledTask New-ScheduledTaskPrincipal LogonType S4U Password RunLevel Highest PowerShell"
|
||
|
||
Links: [{"title":"New-ScheduledTaskPrincipal - PowerShell Command | PDQ","url":"https://www.pdq.com/powershell/new-scheduledtaskprincipal/"},{"title":"Import Scheduled Task with Powershell and S4U - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/184857/import-scheduled-task-with-powershell-and-s4u"},{"title":"Register Scheduled task with S4U Logon type. | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/technet-wiki/40309.register-scheduled-task-with-s4u-logon-type"},{"title":"New-ScheduledTaskPrincipal (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps"},{"title":"Powershell - create scheduled task in Windows Task Scheduler - part 3","url":"https://ciysys.com/blog/powershell-schedule-task-part3.htm"},{"title":"Scheduling a script in Task Scheduler using PowerShell – Jana's Technical blog","url":"https://scripting4ever.wordpress.com/2020/09/21/scheduling-a-script-in-task-scheduler-using-powershell/"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/zh-cn/previous-versions/windows/powershell-scripting/jj649825(v=wps.620)"},{"title":"new scheduledtaskprincipal","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal"},{"title":"new scheduledtask","url":"https://learn.microsoft.com/de-de/powershell/module/scheduledtasks/new-scheduledtask"}]
|
||
|
||
Based on the search results, here's information about using `Register-ScheduledTask`, `New-ScheduledTaskPrincipal`, and the parameters you mentioned:
|
||
|
||
## Overview
|
||
|
||
The `New-ScheduledTaskPrincipal` cmdlet creates an object that contains a scheduled task principal, which is used to run a task under the security context of a specified account. When you use a scheduled task principal, Task Scheduler can run the task regardless of whether that account is logged on.
|
||
|
||
## Key Parameters
|
||
|
||
**LogonType Parameter:**
|
||
The `-LogonType` parameter specifies the security logon method that Task Scheduler uses to run tasks, with acceptable values including None, Password, S4U, Interactive, Group, ServiceAccount, and InteractiveOrPassword.
|
||
|
||
**S4U Logon Type:**
|
||
The S4U (service for user) logon type is used for certain scenarios where no password is stored by the system and there is no access to either the network or encrypted files.
|
||
|
||
**RunLevel Parameter:**
|
||
The RunLevel parameter accepts values of Limited or Highest.
|
||
|
||
## Practical Example
|
||
|
||
A typical implementation would create a principal with S4U logon type and highest run level, then register the scheduled task with the user credentials and password parameter.
|
||
|
||
For server scheduled tasks, S4U logon type is commonly used with the Highest Run Level.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #3] Task Scheduler schema XML StartWhenAvailable RestartOnFailure WakeToRun DisallowStartIfOnBatteries site:learn.microsoft.com
|
||
|
||
Web search results for query: "Task Scheduler schema XML StartWhenAvailable RestartOnFailure WakeToRun DisallowStartIfOnBatteries site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"ITaskSettings::get_DisallowStartIfOnBatteries (taskschd.h) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itasksettings-get_disallowstartifonbatteries"},{"title":"DisallowStartIfOnBatteries (settingsType) Element - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-disallowstartifonbatteries-settingstype-element"},{"title":"settingsType Complex Type - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-settingstype-complextype"},{"title":"task scheduler error 267014 \"process terminated by user\" - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/d8563660-4111-4c83-88a6-f28b72309b6e/task-scheduler-error-267014-process-terminated-by?forum=windows-all"},{"title":"[MS-GPPREF]: ScheduledTasks XML Example | Microsoft Learn","url":"https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-gppref/850b333b-9336-496a-bf93-a20f33748454"},{"title":"Task idle conditions - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/task-idle-conditions"},{"title":"Task Scheduler Schema - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-schema"},{"title":"New-ScheduledTaskSettingsSet (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps"},{"title":"Task Scheduler Schema Elements - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-schema-elements"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/windows/win32/taskschd/tasksettings"}]
|
||
|
||
I found relevant Microsoft Learn documentation about the Task Scheduler schema and the XML elements you're searching for. Here's what the search results show:
|
||
|
||
The settingsType complex type in the Task Scheduler schema includes elements for StartWhenAvailable, RestartOnFailure, DisallowStartIfOnBatteries, and WakeToRun.
|
||
|
||
Specifically:
|
||
|
||
- **DisallowStartIfOnBatteries**: Specifies that the task will not be started if the computer is running on batteries. The default setting for this element is True.
|
||
|
||
- **StartWhenAvailable**: This is a boolean element in the settingsType with a default value of "false".
|
||
|
||
- **RestartOnFailure**: This element is of type "restartType" and is part of the settingsType complex type.
|
||
|
||
- **WakeToRun**: This is a boolean element in the settingsType with a default value of "false".
|
||
|
||
The search results include references to the complete schema definition at https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-settingstype-complextype and other related documentation pages on Microsoft Learn.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #4] sc.exe failure reset actions restart service recovery site:learn.microsoft.com
|
||
|
||
Web search results for query: "sc.exe failure reset actions restart service recovery site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"SC | Microsoft Learn","url":"https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490995(v=technet.10)"},{"title":"Sc failure | Microsoft Learn","url":"https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc742019(v=ws.11)"},{"title":"Create Windows Service using BackgroundService - .NET | Microsoft Learn","url":"https://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service"},{"title":"Troubleshooting System Services | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/technet-wiki/14774.troubleshooting-system-services"},{"title":"Guidelines for Services - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-services"},{"title":"Agent Service Fails to Start on Standalone Server - SQL Server | Microsoft Learn","url":"https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/startup-shutdown/agent-service-fails-start-stand-alone-server"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-r2-and-2008/cc753662(v=ws.11)"},{"title":"How to show details of service","url":"https://learn.microsoft.com/en-us/answers/questions/917245/how-to-show-details-of-service"}]
|
||
|
||
I found several relevant Microsoft Learn articles about using `sc.exe` to configure service failure and recovery actions. Here are the key findings:
|
||
|
||
## SC Failure Command Syntax
|
||
|
||
The basic syntax is: `sc [<ServerName>] failure [<ServiceName>] [reset= <ErrorFreePeriod>] [reboot= <BroadcastMessage>] [command= <CommandLine>] [actions= {"" | {[run/<MS>] | [restart/<MS>] | [reboot/<MS>]}[/...]]`
|
||
|
||
## Key Parameters
|
||
|
||
- **reset=**: Specifies the length of the period (in seconds) with no failures after which the failure count should be reset to 0. This parameter must be used in conjunction with the actions= parameter.
|
||
|
||
- **actions=**: Specifies the failure actions and their delay time (in milliseconds) separated by the forward slash (/). The following actions are valid: run, restart, and reboot. You can specify up to three separate actions with the actions= parameter, to be used the first, second, and third times that a service fails.
|
||
|
||
## Example Commands
|
||
|
||
Example usage: `sc failure msftpsvc reset= 30 actions= restart/5000` and `sc failure dfs reset= 60 actions= reboot/30000`
|
||
|
||
For example: `sc.exe failure ".NET Joke Service" reset= 0 actions= restart/60000/restart/60000/run/1000`
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #5] Playwright Chromium headless Windows service Session 0 isolation NSSM WinSW issue
|
||
|
||
Web search results for query: "Playwright Chromium headless Windows service Session 0 isolation NSSM WinSW issue"
|
||
|
||
Links: [{"title":"[Bug]: Chromium already set to headless=True but error logs still say \"Looks like you launched a headed browser without having a XServer running. Set either 'headless: true' or use 'xvfb-run <your-playwright-app>'\" · Issue #2498 · microsoft/playwright-python","url":"https://github.com/microsoft/playwright-python/issues/2498"},{"title":"Headful chromium on Windows does not launch without '--single-process' · Issue #12174 · microsoft/playwright","url":"https://github.com/microsoft/playwright/issues/12174"},{"title":"[Question]chromium doesn't show up? · Issue #20242 · microsoft/playwright","url":"https://github.com/microsoft/playwright/issues/20242"},{"title":"Headless Chrome Explained: Puppeteer, Playwright, and Managed Browser Infrastructure","url":"https://www.browserless.io/blog/headless-chrome"},{"title":"[Bug]: Unable to launch chromium in headless mode in win11 with v1.49.1. · Issue #34306 · microsoft/playwright","url":"https://github.com/microsoft/playwright/issues/34306"},{"title":"GitHub - microsoft/playwright: Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. · GitHub","url":"https://github.com/microsoft/playwright"},{"title":"[Bug]: chromium-headless-shell · Issue #34508 · microsoft/playwright","url":"https://github.com/microsoft/playwright/issues/34508"},{"title":"How to Run Tests in Playwright Headless Chrome? | BrowserStack","url":"https://www.browserstack.com/guide/playwright-headless-chrome"},{"title":"Playwright (software)","url":"https://en.wikipedia.org/wiki/Playwright_(software)"},{"title":"Browsers | Playwright","url":"https://playwright.dev/docs/browsers"}]
|
||
|
||
Based on the search results, I found relevant information about running Playwright Chromium in Windows services with NSSM:
|
||
|
||
## Key Findings
|
||
|
||
When creating a Windows service with NSSM to run Playwright, the browser runs but the window doesn't show up. This is a known issue reported in the Playwright GitHub repository.
|
||
|
||
The fundamental issue is related to **Session 0 isolation on Windows**. When applications run as Windows services through tools like NSSM or WinSW, they execute in Session 0 (the system session) rather than the user's interactive session. Running the code directly shows the chromium window, but scheduling it as a service prevents the window from displaying.
|
||
|
||
## Related Playwright Issues
|
||
|
||
The search results show this is a documented problem in the Playwright community. In headful mode, Chromium cannot launch without certain arguments on Windows, and there are multiple GitHub issues discussing browser launch problems in Windows service contexts.
|
||
|
||
## Possible Solutions
|
||
|
||
While not explicitly detailed in these search results, the typical workarounds for Session 0 isolation issues include:
|
||
- Running services in a user session rather than Session 0
|
||
- Using headless mode (which is more suitable for service environments)
|
||
- Configuring the service to interact with the desktop
|
||
- Using specialized service wrappers that support session bridging
|
||
|
||
For more specific solutions, you may want to consult the Playwright documentation or check the detailed GitHub issues #20242, #3191, and #12174 mentioned in the results.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #6] BurntToast New-BurntToastNotification button protocol action Windows 11 PowerShell
|
||
|
||
Web search results for query: "BurntToast New-BurntToastNotification button protocol action Windows 11 PowerShell"
|
||
|
||
Links: [{"title":"Display toast notifications with PowerShell's BurntToast module | PDQ","url":"https://www.pdq.com/blog/display-toast-notifications-with-powershell-burnt-toast-module/"},{"title":"Create pop-up notifications from PowerShell with BurntToast","url":"https://www.luisllamas.es/en/burnttoast/"},{"title":"powershell script for system reboot - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/1339894/powershell-script-for-system-reboot"},{"title":"Generate Windows toast notifications with the PowerShell module BurntToast – 4sysops","url":"https://4sysops.com/archives/generate-windows-toast-notifications-with-the-powershell-module-burnttoast/"},{"title":"PowerShell Gallery | New-BurntToastNotification.ps1 0.4","url":"https://www.powershellgallery.com/packages/BurntToast/0.4/Content/New-BurntToastNotification.ps1"},{"title":"Powershell : burnt toast notification - PowerShell Help - PowerShell Forums","url":"https://forums.powershell.org/t/powershell-burnt-toast-notification/24222"},{"title":"Windows Toast Notifications With PowerShell - Wit IT - BurnToast Module","url":"https://witit.blog/windows-toast-notifications-with-powershell/"},{"title":"Reboot Notifications with BurntToast: A Simple Guide | Joshua Dearing","url":"https://www.dearing.dev/posts/Reboot-Notifications-with-BurntToast-A-Simple-Guide/"},{"title":"Efficient Notifications Using PowerShell BurntToast","url":"https://www.psplaybook.com/2024/12/03/custom-powershell-notification-script-using-burnttoast-module/"}]
|
||
|
||
I found search results related to your query about BurntToast's `New-BurntToastNotification` button functionality with protocol actions in PowerShell for Windows 11.
|
||
|
||
Here are the key findings:
|
||
|
||
**Basic Button Functionality:**
|
||
You can place a button on toasts that can take you to places all over the web using New-BTButton with the -Arguments parameter to specify a URL.
|
||
|
||
**Protocol Action Type:**
|
||
The `-ActivationType Protocol` parameter is used when creating buttons with New-BTButton to enable protocol-based actions. This allows buttons to trigger specific actions or protocols when clicked.
|
||
|
||
**Example Usage:**
|
||
You can create multiple buttons with different actions like "Restart Now", "Snooze", and "Dismiss" each with their own -Arguments values and -ActivationType Protocol setting.
|
||
|
||
**Windows Compatibility:**
|
||
The BurntToast module works with Windows PowerShell 5.1 and PowerShell 7.3.12 on Windows 10/11 systems.
|
||
|
||
The search results show practical examples of implementing interactive buttons with protocol activation types in BurntToast notifications for Windows 11 environments.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #7] healthchecks.io dead man switch cron ping Windows PowerShell Invoke-RestMethod
|
||
|
||
Web search results for query: "healthchecks.io dead man switch cron ping Windows PowerShell Invoke-RestMethod"
|
||
|
||
Links: [{"title":"Monitor PowerShell Scripts with Healthchecks.io","url":"https://healthchecks.io/docs/powershell/"},{"title":"PowerShell - devroom.io Healthchecks","url":"https://healthchecks.devroom.io/docs/powershell/"},{"title":"Documentation - WMIT Watchdog","url":"https://healthchecks.it.wm.edu/docs/"},{"title":"How to Monitor Cron Jobs with Healthchecks.io","url":"https://healthchecks.io/docs/monitoring_cron_jobs/"},{"title":"Healthchecks.io Documentation - Healthchecks.io","url":"https://healthchecks.io/docs/"},{"title":"Healthchecks.io: The Ultimate Guide to Application and Cron Job Monitoring | by Nisheet Das | Medium","url":"https://medium.com/@nisheet110/healthchecks-io-the-ultimate-guide-to-application-and-cron-job-monitoring-fd1b6bf311fc"},{"title":"PowerShell - Healthchecks","url":"https://healthchecks.verbis.dkfz.de/docs/powershell/"},{"title":"Documentation - Async Healthchecks","url":"https://hc.async.com.br/docs/"},{"title":"PowerShell - RDSec Healthchecks.io","url":"https://healthchecks.cloud.rdsec.nl/docs/powershell/"},{"title":"PowerShell - Health Checks","url":"https://healthchecks.iqusong.com/docs/powershell/"}]
|
||
|
||
I found comprehensive search results for your query. Here's what the documentation shows:
|
||
|
||
## Overview
|
||
|
||
Healthchecks.io works as a dead man's switch for processes that need to run continuously or on a regular, known schedule. This monitoring technique, sometimes called "heartbeat monitoring", is a type of dead man's switch.
|
||
|
||
## How It Works
|
||
|
||
Your cron job sends an HTTP request ("ping") to Healthchecks.io every time it completes. When Healthchecks.io does not receive the HTTP request at the expected time, it notifies you.
|
||
|
||
## PowerShell Implementation
|
||
|
||
For Windows environments, from within a PowerShell script, it is also easy to ping Healthchecks.io. When scheduled to run with Task Scheduler, it will send regular "I'm alive" messages.
|
||
|
||
The basic command structure is:
|
||
|
||
Invoke-RestMethod https://hc-ping.com/your-uuid-here
|
||
|
||
You can also send diagnostic information with POST requests: Invoke-RestMethod -Uri https://hc-ping.com/your-uuid-here -Method Post -Body "temperature=-7"
|
||
|
||
For scheduling, you can pass the command to PowerShell directly: powershell.exe -Command "&{Invoke-RestMethod https://hc-ping.com/your-uuid-here}"
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #8] Task Scheduler "Run whether user is logged on or not" S4U interactive desktop toast notification not shown
|
||
|
||
Web search results for query: "Task Scheduler "Run whether user is logged on or not" S4U interactive desktop toast notification not shown"
|
||
|
||
Links: [{"title":"Run whether user is logged on or not · Issue #44 · bnosac/taskscheduleR","url":"https://github.com/bnosac/taskscheduleR/issues/44"},{"title":"scheduler tasks with security options “Run whether user is logged on or not”. - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/5789906/scheduler-tasks-with-security-options-run-whether"},{"title":"Register Scheduled task with S4U Logon type. | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/technet-wiki/40309.register-scheduled-task-with-s4u-logon-type"},{"title":"windows - Task Scheduler (run whether user is logged on or not)","url":"https://www.iditect.com/program-example/windows--task-scheduler-run-whether-user-is-logged-on-or-not.html"},{"title":"Fixing Task Scheduler Tasks That Don't Run or Exit 0x1 | KomuraSoft LLC Blog","url":"https://comcomponent.com/en/blog/windows-task-scheduler-reliable-scheduled-tasks/"},{"title":"Show App UI at Logon with Windows 11 Task Scheduler","url":"https://windowsforum.com/threads/show-app-ui-at-logon-with-windows-11-task-scheduler.392418/"},{"title":"task scheduler error a specified logon session does not exist","url":"https://learn.microsoft.com/en-us/archive/blogs/supportingwindows/task-scheduler-error-a-specified-logon-session-does-not-exist"},{"title":"Task Scheduler is not working with option Run wheather user logged on or not in user context","url":"https://learn.microsoft.com/en-gb/answers/questions/2141588/task-scheduler-is-not-working-with-option-run-whea"}]
|
||
|
||
I've performed the web search for your query about Task Scheduler's "Run whether user is logged on or not" setting with S4U and interactive desktop toast notifications.
|
||
|
||
Here are the key findings from the search results:
|
||
|
||
**Core Issue - Non-Interactive Sessions:**
|
||
When a task runs as SYSTEM with TaskLogonType.ServiceAccount and "Run whether user is logged on or not", it runs in a non-interactive session. Tasks that run when the user is not logged on do not have access to the user's interactive desktop, so if your task interacts with desktop elements or requires user input, it may not work as expected.
|
||
|
||
**Why Toast Notifications Won't Show:**
|
||
A task launching a GUI app was registered as "run regardless." The app was in fact running, but its window was nowhere to be seen because it runs in a non-interactive session — anything that requires an interactive display fundamentally cannot work under this configuration.
|
||
|
||
**S4U (Service for User) Specifics:**
|
||
A script that accesses a shared folder was registered with "Do not store password" (S4U). This is because S4U has no network credentials.
|
||
|
||
**Key Design Principle:**
|
||
If your scheduled task runs in a non-interactive session or under a different session context than the desktop user, the application process may be present but its windows will not be visible to the logged-on user. This is not a bug — it's by design.
|
||
|
||
The search results make clear that toast notifications and interactive desktop elements cannot appear when using the "Run whether user is logged on or not" setting because the task runs in an isolated, non-interactive session by design.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [FETCH #1] https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps
|
||
**ASK:** List all parameters with their exact names, types, and descriptions, especially: StartWhenAvailable, RestartCount, RestartInterval, WakeToRun, ExecutionTimeLimit, MultipleInstances (allowed values), AllowStartIfOnBatteries, DontStopIfGoingOnBatteries, RunOnlyIfNetworkAvailable, DontStopOnIdleEnd, Compatibility, Hidden, Priority, DisallowDemandStart. Include any noted constraints (e.g. RestartInter
|
||
…[truncated 47 chars]
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
defaultMoniker: windowsserver2025-ps
|
||
versioningType: Ranged
|
||
title: New-ScheduledTaskSettingsSet (ScheduledTasks) | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps
|
||
config_moniker_range: WindowsServer2025-ps
|
||
uid: ScheduledTasks.New-ScheduledTaskSettingsSet
|
||
module: ScheduledTasks
|
||
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/windows/get-started
|
||
author: robinharwood
|
||
breadcrumb_path: /powershell/windows/bread/toc.json
|
||
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
||
feedback_system: Standard
|
||
manager: eliotgra
|
||
ms.author: roharwoo
|
||
ms.devlang: powershell
|
||
ms.service: windows-11
|
||
ms.topic: reference
|
||
uhfHeaderId: MSDocsHeader-M365-IT
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56754133-c3c3-4a9f-af19-71bdbe19fccf
|
||
document type: cmdlet
|
||
external help file: PS_ScheduledTask_v1.0.cdxml-help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps&wt.mc_id=ps-gethelp
|
||
Module Name: ScheduledTasks
|
||
ms.date: 2016-12-20T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 9769fc96-d3d3-bcf7-8296-a3bec1fa60cc
|
||
document_version_independent_id: 888eb5d6-f001-3779-7b0a-77bcb629d93d
|
||
updated_at: 2025-05-14T22:44:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/live/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskSettingsSet.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/0ef3f225d29e26d1cf3119f37dfff70bb6165746/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskSettingsSet.md
|
||
git_commit_id: 0ef3f225d29e26d1cf3119f37dfff70bb6165746
|
||
default_moniker: windowsserver2025-ps
|
||
site_name: Docs
|
||
depot_name: TechNet.windows-powershell
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../windowsserver2025-ps/toc.json
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
asset_id: module/scheduledtasks/new-scheduledtasksettingsset
|
||
moniker_range_name: ffb05b7b47577225af7c7b6a20151268
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
item_type: Content
|
||
source_path: docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskSettingsSet.md
|
||
cmProducts: []
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 6fe91ae3-5ef9-4eb6-66e6-6df977989fcd
|
||
---
|
||
|
||
# New-ScheduledTaskSettingsSet
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [ScheduledTasks Module](./)
|
||
|
||
|
||
|
||
Creates a new scheduled task settings object.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### Default (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskSettingsSet
|
||
|
||
[-DisallowDemandStart]
|
||
|
||
[-DisallowHardTerminate]
|
||
|
||
[-Compatibility <CompatibilityEnum>]
|
||
|
||
[-DeleteExpiredTaskAfter <TimeSpan>]
|
||
|
||
[-AllowStartIfOnBatteries]
|
||
|
||
[-Disable]
|
||
|
||
[-MaintenanceExclusive]
|
||
|
||
[-Hidden]
|
||
|
||
[-RunOnlyIfIdle]
|
||
|
||
[-IdleWaitTimeout <TimeSpan>]
|
||
|
||
[-NetworkId <String>]
|
||
|
||
[-NetworkName <String>]
|
||
|
||
[-DisallowStartOnRemoteAppSession]
|
||
|
||
[-MaintenancePeriod <TimeSpan>]
|
||
|
||
[-MaintenanceDeadline <TimeSpan>]
|
||
|
||
[-StartWhenAvailable]
|
||
|
||
[-DontStopIfGoingOnBatteries]
|
||
|
||
[-WakeToRun]
|
||
|
||
[-IdleDuration <TimeSpan>]
|
||
|
||
[-RestartOnIdle]
|
||
|
||
[-DontStopOnIdleEnd]
|
||
|
||
[-ExecutionTimeLimit <TimeSpan>]
|
||
|
||
[-MultipleInstances <MultipleInstancesEnum>]
|
||
|
||
[-Priority <Int32>]
|
||
|
||
[-RestartCount <Int32>]
|
||
|
||
[-RestartInterval <TimeSpan>]
|
||
|
||
[-RunOnlyIfNetworkAvailable]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
The **New-ScheduledTaskSettingsSet** cmdlet creates an object that contains scheduled task settings. Each scheduled task has one set of task settings. Use this cmdlet to configure options to manage the behavior of the task upon completion, to manage the behavior of the task if a problem occurs, or to manage the behavior of the task if an instance of the task is already running.
|
||
|
||
|
||
|
||
You can use the scheduled task settings to register a new scheduled task or update an existing task registration.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1: Register a scheduled task that uses default task settings
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
PS C:\>$STSet = New-ScheduledTaskSettingsSet
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $STSet
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that use the default settings and assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd and to use the default task settings.
|
||
|
||
|
||
|
||
This example registers a scheduled task that uses default task settings.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
### Example 2: Set the priority of a scheduled task
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
PS C:\>$STSet = New-ScheduledTaskSettingsSet -Priority 5
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that sets a higher priority for the scheduled task, and assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that have a priority setting of 5.
|
||
|
||
|
||
|
||
This example sets the priority of a scheduled task.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
### Example 3: Set restart settings for a scheduled task
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 60)
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that specify that Task Scheduler attempts three restarts of the task at sixty minute intervals. This command assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that the **ScheduledTaskSettings** object defines.
|
||
|
||
|
||
|
||
This example sets restart settings for a scheduled task.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
### Example 4: Set idle settings for a scheduled task
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RunOnlyIfIdle -IdleDuration 00:02:00 -IdleWaitTimeout 02:30:00
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that specify that Task Scheduler runs the task only when the computer is idle for 2 minutes and waits for 2 hours and 30 minutes for an idle condition. This command assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd and to use the task settings that the **ScheduledTaskSettings** object defines.
|
||
|
||
|
||
|
||
This example sets idle settings for a scheduled task.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
### Example 5: Register a scheduled task that runs only when a network is available
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
PS C:\>$Stset = New-ScheduledTaskSettingsSet -RunOnlyIfNetworkAvailable
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that specify that Task Scheduler runs the task only when a network is available. This command assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd only when a network is available.
|
||
|
||
|
||
|
||
This example registers a scheduled task that runs only when a network is available.
|
||
|
||
|
||
|
||
### Example 6: Register a scheduled task that has a time limit to complete the task
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
$Stset = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 1)
|
||
|
||
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
|
||
|
||
|
||
|
||
```
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the ScheduledTaskAction object to the $Sta variable.
|
||
|
||
|
||
|
||
The second command creates scheduled task settings that specify if the task is not finished after one hour, it is considered as failed. This command assigns the **ScheduledTaskSettings** object to the $Stset variable.
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd, only then finish the task after one hour.
|
||
|
||
|
||
|
||
Without the ExecutionTimeLimit setting defined, the time limit set to it's default of three days for the Task Scheduler is allowed to complete the task. To configure the time limit, see [New-TimeSpan](/en-us/powershell/module/microsoft.powershell.utility/new-timespan).
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -AllowStartIfOnBatteries
|
||
|
||
|
||
|
||
Indicates that Task Scheduler starts if the computer is running on battery power.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -AsJob
|
||
|
||
|
||
|
||
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -CimSession
|
||
|
||
|
||
|
||
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a [New-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227967) or [Get-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227966) cmdlet. The default is the current session on the local computer.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimSession[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | Session |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Compatibility
|
||
|
||
|
||
|
||
Indicates which version of Task Scheduler with which a task is compatible. The acceptable values for this parameter are:
|
||
|
||
|
||
|
||
- At
|
||
|
||
- V1
|
||
|
||
- Vista
|
||
|
||
- Win7
|
||
|
||
- Win8
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CompatibilityEnum |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | At, V1, Vista, Win7, Win8 |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -DeleteExpiredTaskAfter
|
||
|
||
|
||
|
||
Specifies the amount of time that Task Scheduler waits before deleting the task after it expires.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | TimeSpan |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Disable
|
||
|
||
|
||
|
||
Indicates that the task is disabled.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -DisallowDemandStart
|
||
|
||
|
||
|
||
Indicates that the task cannot be started by using either the Run command or the Context menu.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontSho
|
||
…[truncated 14373 chars]
|
||
|
||
## [FETCH #2] https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps
|
||
**ASK:** List all parameters and their allowed values (LogonType values and meanings, RunLevel values, UserId, GroupId, ProcessTokenSidType). Quote the description of S4U, Password, Interactive, InteractiveOrPassword, ServiceAccount logon types exactly.
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
defaultMoniker: windowsserver2025-ps
|
||
versioningType: Ranged
|
||
title: New-ScheduledTaskPrincipal (ScheduledTasks) | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps
|
||
config_moniker_range: WindowsServer2025-ps
|
||
uid: ScheduledTasks.New-ScheduledTaskPrincipal
|
||
module: ScheduledTasks
|
||
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/windows/get-started
|
||
author: robinharwood
|
||
breadcrumb_path: /powershell/windows/bread/toc.json
|
||
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
||
feedback_system: Standard
|
||
manager: eliotgra
|
||
ms.author: roharwoo
|
||
ms.devlang: powershell
|
||
ms.service: windows-11
|
||
ms.topic: reference
|
||
uhfHeaderId: MSDocsHeader-M365-IT
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56754133-c3c3-4a9f-af19-71bdbe19fccf
|
||
document type: cmdlet
|
||
external help file: PS_ScheduledTask_v1.0.cdxml-help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps&wt.mc_id=ps-gethelp
|
||
Module Name: ScheduledTasks
|
||
ms.date: 2016-12-20T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: c9fc8814-df7c-1f33-e1b1-95eabedd5fdd
|
||
document_version_independent_id: a877ea34-1338-f7dc-54e4-64be217cf034
|
||
updated_at: 2025-05-14T22:44:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/live/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/0ef3f225d29e26d1cf3119f37dfff70bb6165746/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
|
||
git_commit_id: 0ef3f225d29e26d1cf3119f37dfff70bb6165746
|
||
default_moniker: windowsserver2025-ps
|
||
site_name: Docs
|
||
depot_name: TechNet.windows-powershell
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../windowsserver2025-ps/toc.json
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
asset_id: module/scheduledtasks/new-scheduledtaskprincipal
|
||
moniker_range_name: ffb05b7b47577225af7c7b6a20151268
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
item_type: Content
|
||
source_path: docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 217d14e4-c2eb-f8fa-f319-62e14d9d0179
|
||
---
|
||
|
||
# New-ScheduledTaskPrincipal
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [ScheduledTasks Module](./)
|
||
|
||
|
||
|
||
Creates an object that contains a scheduled task principal.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### User (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskPrincipal
|
||
|
||
[[-Id] <String>]
|
||
|
||
[[-RunLevel] <RunLevelEnum>]
|
||
|
||
[[-ProcessTokenSidType] <ProcessTokenSidTypeEnum>]
|
||
|
||
[[-RequiredPrivilege] <String[]>]
|
||
|
||
[-UserId] <String>
|
||
|
||
[[-LogonType] <LogonTypeEnum>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Group
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskPrincipal
|
||
|
||
[-GroupId] <String>
|
||
|
||
[[-Id] <String>]
|
||
|
||
[[-RunLevel] <RunLevelEnum>]
|
||
|
||
[[-ProcessTokenSidType] <ProcessTokenSidTypeEnum>]
|
||
|
||
[[-RequiredPrivilege] <String[]>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
The **New-ScheduledTaskPrincipal** cmdlet creates an object that contains a scheduled task principal. Use a scheduled task principal to run a task under the security context of a specified account. When you use a scheduled task principal, Task Scheduler can run the task regardless of whether that account is logged on.
|
||
|
||
|
||
|
||
You can use the definition of a scheduled task principal to register a new scheduled task or update an existing task registration.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1: Register a scheduled task by using a user ID for a task principal
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
|
||
|
||
The second command creates a scheduled task principal. The **New-ScheduledTaskPrincipal** cmdlet specifies that Task Scheduler uses the Local Service account to run tasks, and that the Local Service account uses the Service Account logon. The command assigns the **ScheduledTaskPrincipal** object to the $STPrin variable.
|
||
|
||
PS C:\>$STPrin = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd. The **Principal** parameter specifies that the Task Scheduler uses the Local Service account to run the task.
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Principal $STPrin
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that will run as the Local Service account.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
### Example 2: Register a scheduled task by using a user group for a task principal
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction cmd
|
||
|
||
|
||
|
||
The second command creates a scheduled task principal. The **New-ScheduledTaskPrincipal** cmdlet specifies that Task Scheduler uses the Administrators user group that has the highest privileges to run tasks. The command assigns the **ScheduledTaskPrincipal** object to the $STPrin variable.
|
||
|
||
PS C:\>$STPrin = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Administrators" -RunLevel Highest
|
||
|
||
|
||
|
||
The third command registers the scheduled task Task01 to run the task action named Cmd. The *Principal* parameter specifies that Task Scheduler uses the Administrators user group to run the task.
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Principal $STPrin
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that runs under logged-in members of the Administrators user group that has the highest privileges.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -AsJob
|
||
|
||
|
||
|
||
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -CimSession
|
||
|
||
|
||
|
||
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a [New-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227967) or [Get-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227966) cmdlet. The default is the current session on the local computer.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimSession[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | Session |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -GroupId
|
||
|
||
|
||
|
||
Specifies the ID of a user group that Task Scheduler uses to run the tasks that are associated with the principal.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Group
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Id
|
||
|
||
|
||
|
||
Specifies the ID of a scheduled task principal.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 5 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -LogonType
|
||
|
||
|
||
|
||
Specifies the security logon method that Task Scheduler uses to run the tasks that are associated with the principal. The acceptable values for this parameter are:
|
||
|
||
|
||
|
||
- None
|
||
|
||
- Password
|
||
|
||
- S4U
|
||
|
||
- Interactive
|
||
|
||
- Group
|
||
|
||
- ServiceAccount
|
||
|
||
- InteractiveOrPassword
|
||
|
||
|
||
|
||
For more information about LogonType values, see [Principal.LogonType](/en-us/windows/win32/taskschd/principal-logontype#property-value)
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | LogonTypeEnum |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | None, Password, S4U, Interactive, Group, ServiceAccount, InteractiveOrPassword |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 1 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ProcessTokenSidType
|
||
|
||
|
||
|
||
Specifies the security ID (SID) type of the process token. The acceptable values for this parameter are:
|
||
|
||
|
||
|
||
- None
|
||
|
||
- Unrestricted
|
||
|
||
- Default
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | ProcessTokenSidTypeEnum |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | None, Unrestricted, Default |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 3 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -RequiredPrivilege
|
||
|
||
|
||
|
||
Specifies an array of user rights that Task Scheduler uses to run the tasks that are associated with the principal. Specify the constant name that is associated with a user right.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -RunLevel
|
||
|
||
|
||
|
||
Specifies the level of user rights that Task Scheduler uses to run the tasks that are associated with the principal. The acceptable values for this parameter are:
|
||
|
||
|
||
|
||
- Highest. Tasks run by using the highest privileges.
|
||
|
||
- Limited. Tasks run by using the least-privileged user account (LUA).
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | RunLevelEnum |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | Limited, Highest |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ThrottleLimit
|
||
|
||
|
||
|
||
Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of `0` is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | Int32 |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -UserId
|
||
|
||
|
||
|
||
Specifies the user ID that Task Scheduler uses to run the tasks that are associated with the principal.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### CommonParameters
|
||
|
||
|
||
|
||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
|
||
|
||
|
||
|
||
## Outputs
|
||
|
||
|
||
|
||
### [CimInstance](/en-us/dotnet/api/microsoft.management.infrastructure.ciminstance#MSFT_TaskPrincipal)
|
||
|
||
|
||
|
||
## Related Links
|
||
|
||
|
||
|
||
- [Get-ScheduledTaskInfo](get-scheduledtaskinfo)
|
||
|
||
- [New-ScheduledTaskAction](new-scheduledtaskaction)
|
||
|
||
- [New-ScheduledTaskSettingsSet](new-scheduledtasksettingsset)
|
||
|
||
- [New-ScheduledTaskTrigger](new-scheduledtasktrigger)
|
||
|
||
- [Register-ScheduledTask](register-scheduledtask)
|
||
|
||
---
|
||
|
||
## Other Supported Versions
|
||
|
||
- [windowsserver2016-ps](https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2016-ps&accept=text/markdown)
|
||
- [windowsserver2019-ps](https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2019-ps&accept=text/markdown)
|
||
- [windowsserver2022-ps](https://learn.microsoft.com/en-us/pow
|
||
…[truncated 105 chars]
|
||
|
||
## [FETCH #3] https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-settingstype-complextype
|
||
**ASK:** List all child elements of settingsType with their types and default values (AllowStartOnDemand, RestartOnFailure, MultipleInstancesPolicy, DisallowStartIfOnBatteries, StopIfGoingOnBatteries, AllowHardTerminate, StartWhenAvailable, NetworkProfileName, RunOnlyIfNetworkAvailable, WakeToRun, Enabled, Hidden, DeleteExpiredTaskAfter, IdleSettings, NetworkSettings, ExecutionTimeLimit, Priority, RunOnlyI
|
||
…[truncated 90 chars]
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: settingsType Complex Type - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-settingstype-complextype
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Defines the child elements and sequencing information for the Settings (taskType) element.
|
||
ms.assetid: dba6b82d-aaa4-4f77-aeb1-c5a8f81aec25
|
||
keywords:
|
||
- settingsType complex type Task Scheduler
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- settingsType
|
||
api_type:
|
||
- Schema
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
api_location:
|
||
locale: en-us
|
||
document_id: 5c115ec7-5cee-73ec-b9b9-bcdb7a2ba6e0
|
||
document_version_independent_id: 33b0e90e-d5f4-acaa-38c6-2e82bf374e29
|
||
updated_at: 2020-12-11T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/taskschedulerschema-settingstype-complextype.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/2ec0df659644a793ed4f6160f238a95c9d9a9dcf/desktop-src/TaskSchd/taskschedulerschema-settingstype-complextype.md
|
||
git_commit_id: 2ec0df659644a793ed4f6160f238a95c9d9a9dcf
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 557
|
||
asset_id: taskschd/taskschedulerschema-settingstype-complextype
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/taskschedulerschema-settingstype-complextype.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 12f648c7-709f-2992-cda8-bb9c63c8487d
|
||
---
|
||
|
||
# settingsType Complex Type - Win32 apps | Microsoft Learn
|
||
|
||
Defines the child elements and sequencing information for the [**Settings (taskType)**](taskschedulerschema-settings-tasktype-element) element.
|
||
|
||
|
||
|
||
```syntax
|
||
|
||
<xs:complexType name="settingsType">
|
||
|
||
<xs:all>
|
||
|
||
<xs:element name="AllowStartOnDemand"
|
||
|
||
type="boolean"
|
||
|
||
default="true"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="RestartOnFailure"
|
||
|
||
type="restartType"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="MultipleInstancesPolicy"
|
||
|
||
type="multipleInstancesPolicyType"
|
||
|
||
default="IgnoreNew"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="DisallowStartIfOnBatteries"
|
||
|
||
type="boolean"
|
||
|
||
default="true"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="StopIfGoingOnBatteries"
|
||
|
||
type="boolean"
|
||
|
||
default="true"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="AllowHardTerminate"
|
||
|
||
type="boolean"
|
||
|
||
default="true"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="StartWhenAvailable"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="NetworkProfileName"
|
||
|
||
type="string"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="RunOnlyIfNetworkAvailable"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="WakeToRun"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="Enabled"
|
||
|
||
type="boolean"
|
||
|
||
default="true"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="Hidden"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="DeleteExpiredTaskAfter"
|
||
|
||
type="duration"
|
||
|
||
default="PT0S"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="IdleSettings"
|
||
|
||
type="idleSettingsType"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="NetworkSettings"
|
||
|
||
type="networkSettingsType"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="ExecutionTimeLimit"
|
||
|
||
type="duration"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="Priority"
|
||
|
||
type="priorityType"
|
||
|
||
default="7"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="RunOnlyIfIdle"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="UseUnifiedSchedulingEngine"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
<xs:element name="DisallowStartOnRemoteAppSession"
|
||
|
||
type="boolean"
|
||
|
||
default="false"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
</xs:all>
|
||
|
||
</xs:complexType>
|
||
|
||
```
|
||
|
||
|
||
|
||
## Child elements
|
||
|
||
|
||
|
||
| Element | Type | Description |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| [**AllowHardTerminate**](taskschedulerschema-allowhardterminate-settingstype-element) | boolean | Specifies if the Task Scheduler service allows hard termination of the task. |
|
||
|
||
| [**AllowStartOnDemand**](taskschedulerschema-allowstartondemand-settingstype-element) | boolean | Specifies that the task can be started by using either the Run command or the Context menu. |
|
||
|
||
| [**DeleteExpiredTaskAfter**](taskschedulerschema-deleteexpiredtaskafter-settingstype-element) | duration | Specifies the amount of time that the Task Scheduler will wait before deleting the task after it expires. If no value is specified for this element, then the Task Scheduler service will not delete the task. |
|
||
|
||
| [**DisallowStartIfOnBatteries**](taskschedulerschema-disallowstartifonbatteries-settingstype-element) | boolean | Specifies that the task will not be started if the computer is running on battery power. |
|
||
|
||
| [**DisallowStartOnRemoteAppSession**](taskschedulerschema-disallowstartonremoteappsession-settingstype-element) | boolean | Specifies that the task should not start if the task is triggered to run in a Remote Applications Integrated Locally (RAIL) session. |
|
||
|
||
| [**Enabled**](taskschedulerschema-enabled-settingstype-element) | boolean | Specifies that the task is enabled. The task can be performed only when this setting is **True**. |
|
||
|
||
| [**ExecutionTimeLimit**](taskschedulerschema-executiontimelimit-settingstype-element) | duration | Specifies the amount of time allowed to complete the task. |
|
||
|
||
| [**Hidden**](taskschedulerschema-hidden-settingstype-element) | boolean | Specifies, by default, that the task will not be visible in the user interface (UI). |
|
||
|
||
| [**IdleSettings**](taskschedulerschema-idlesettings-settingstype-element) | [**idleSettingsType**](taskschedulerschema-idlesettingstype-complextype) | Specifies how the Task Scheduler performs tasks when the computer is in an idle state. |
|
||
|
||
| [**MultipleInstancesPolicy**](taskschedulerschema-multipleinstancespolicy-settingstype-element) | [**multipleInstancesPolicyType**](taskschedulerschema-multipleinstancespolicytype-simpletype) | Specifies the policy that defines how the Task Scheduler deals with multiple instances of the task. |
|
||
|
||
| [**NetworkProfileName**](taskschedulerschema-networkprofilename-settingstype-element) | string | Specifies the name of a network profile. The Task Scheduler service verifies the availability of this network when the [**RunOnlyIfNetworkAvailable**](taskschedulerschema-runonlyifnetworkavailable-settingstype-element) element is set to **True**. The name is used for display purposes. |
|
||
|
||
| [**NetworkSettings**](taskschedulerschema-networksettings-settingstype-element) | [**networkSettingsType**](taskschedulerschema-networksettingstype-complextype) | Specifies the settings that the Task Scheduler service uses to obtain a network profile. The Task Scheduler service checks the availability of this network when the [**RunOnlyIfNetworkAvailable**](taskschedulerschema-runonlyifnetworkavailable-settingstype-element) element is set to **True**. |
|
||
|
||
| [**Priority**](taskschedulerschema-priority-settingstype-element) | [**priorityType**](taskschedulerschema-prioritytype-simpletype) | Specifies the priority level for the task. |
|
||
|
||
| [**RestartOnFailure**](taskschedulerschema-restartonfailure-settingstype-element) | [**restartType**](taskschedulerschema-restarttype-complextype) | Specifies that the Task Scheduler will attempt to restart the task if it fails for any reason. |
|
||
|
||
| [**RunOnlyIfIdle**](taskschedulerschema-runonlyifidle-settingstype-element) | boolean | Specifies that the task is run only when the computer is in an idle state. |
|
||
|
||
| [**RunOnlyIfNetworkAvailable**](taskschedulerschema-runonlyifnetworkavailable-settingstype-element) | boolean | Specifies that the Task Scheduler will run the task only when a network is available. |
|
||
|
||
| [**StartWhenAvailable**](taskschedulerschema-startwhenavailable-settingstype-element) | boolean | Specifies that the Task Scheduler can start the task at any time after its scheduled time has passed. |
|
||
|
||
| [**StopIfGoingOnBatteries**](taskschedulerschema-stopifgoingonbatteries-settingstype-element) | boolean | Specifies that the task will be stopped if the computer switches to battery power. |
|
||
|
||
| [**UseUnifiedSchedulingEngine**](taskschedulerschema-useunifiedschedulingengine-settingstype-element) | boolean | Specifies that the task is run by using the Unified Scheduling Engine. |
|
||
|
||
| [**WakeToRun**](taskschedulerschema-waketorun-settingstype-element) | boolean | Specifies that Task Scheduler will wake the computer before it runs the task. |
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
## [FETCH #4] https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc742019(v=ws.11)
|
||
**ASK:** Give the exact syntax of sc failure, all parameters (reset=, reboot=, command=, actions=), the meaning of the delay units, the 'reset=' units (seconds vs milliseconds), the note about spaces after '=' and any examples. Also whether 'sc failureflag' is mentioned.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Sc failure | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc742019(v=ws.11)
|
||
breadcrumb_path: /previous-versions/windows/it-pro/breadcrumb/toc.json
|
||
current_version_url: https://docs.microsoft.com/windows-server/windows-server
|
||
is_archived: true
|
||
uhfHeaderId: MSDocsHeader-Archive
|
||
ms.author: Archiveddocs
|
||
ms.prod: windows-server-2012-R2-and-2012
|
||
ms.topic: archived
|
||
author: Archiveddocs
|
||
TOCTitle: Sc failure
|
||
ms:assetid: 0b2187df-98e3-466e-bf54-805807d9abfa
|
||
ms:mtpsurl: https://technet.microsoft.com/en-us/library/Cc742019(v=WS.11)
|
||
ms:contentKeyID: 48765806
|
||
ms.date: 2016-08-31T00:00:00.0000000Z
|
||
mtps_version: v=WS.11
|
||
locale: en-us
|
||
document_id: 8f0e6eef-a192-9de5-0058-eda7a626269b
|
||
document_version_independent_id: 8f0e6eef-a192-9de5-0058-eda7a626269b
|
||
updated_at: 2021-11-12T17:51:00.0000000Z
|
||
original_content_git_url: https://docs-archive.visualstudio.com/DefaultCollection/docs-archive-project/_git/windows-itpro-docs-archive-2-pr?path=/windows-server-2012-and-2012-R2/cc742019(v=ws.11).md&version=GBlive&_a=contents
|
||
gitcommit: https://docs-archive.visualstudio.com/DefaultCollection/docs-archive-project/_git/windows-itpro-docs-archive-2-pr/commit/5327995ac358bee6eaf26e4214a7ac52b67607f1?path=/windows-server-2012-and-2012-R2/cc742019(v=ws.11).md&_a=contents
|
||
git_commit_id: 5327995ac358bee6eaf26e4214a7ac52b67607f1
|
||
site_name: Docs
|
||
depot_name: MSDN.windows-server-2012-and-2012-R2
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
feedback_system: None
|
||
feedback_product_url: ''
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 495
|
||
asset_id: cc742019(v=ws.11)
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: windows-server-2012-and-2012-R2/cc742019(v=ws.11).md
|
||
platformId: fb84ee79-b932-7779-dfff-2c6fff46e78a
|
||
---
|
||
|
||
# Sc failure | Microsoft Learn
|
||
|
||
Applies To: Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012, Windows Server 2003 with SP1, Windows 8
|
||
|
||
|
||
|
||
Specifies one or more actions to take if a service fails.
|
||
|
||
|
||
|
||
For examples of how to use this command, see Examples.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
```
|
||
|
||
sc [<ServerName>] failure [<ServiceName>] [reset= <ErrorFreePeriod>] [reboot= <BroadcastMessage>] [command= <CommandLine>] [actions= {"" | {[run/<MS>] | [restart/<MS>] | [reboot/<MS>]}[/...]]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
| Parameter | Description |
|
||
|
||
| --- | --- |
|
||
|
||
| <ServerName> | Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format (for example, \\myserver). To run SC.exe locally, omit this parameter. |
|
||
|
||
| <ServiceName> | Specifies the service name returned by the **getkeyname** operation. |
|
||
|
||
| reset= <ErrorFreePeriod> | Specifies the length of the period (in seconds) with no failures after which the failure count should be reset to **0** (zero). Note that this parameter requires the **actions=** parameter. |
|
||
|
||
| reboot= <BroadcastMessage> | Specifies the message to be broadcast when a service fails. |
|
||
|
||
| command= <CommandLine> | Specifies the command-line command to be run when the specified service fails. For more information about how to run a batch or VBS file on failure, see Remarks. |
|
||
|
||
| actions= {"" | {[run/<MS>] | [restart/<MS>] | [reboot/<MS>]}[/...] | Specifies one or more failure actions and their delay times (in milliseconds), separated by a forward slash (/). Valid actions are **run**, **restart**, and **reboot**. If more than one action is specified, each action must be separated by a forward slash. Use **actions= ""** to take no action a service fails. Note that this parameter requires the **reset=** parameter. |
|
||
|
||
| /? | Displays help at the command prompt. |
|
||
|
||
|
||
|
||
## Remarks
|
||
|
||
|
||
|
||
- Not all services allow changes to their failure options. Some run as part of a service set.
|
||
|
||
- To run a batch file when a service fails, specify **command=***Cmd*.exe\*\* \*\**Drive*:\*FileName*.bat, where *Drive*:\*FileName*.bat is the fully qualified name of the batch file.
|
||
|
||
- To run a VBS file when a service fails, specify **command=***Cscript* *Drive*:\*MyScript*.vbs, where *Drive*:\*MyScript*.vbs is the fully qualified name of the script file.
|
||
|
||
- You can specify up to three separate actions with the **actions=** parameter, to be used the first, second, and third times that a service fails.
|
||
|
||
- For each command-line option (parameter), the equal sign is part of the option name.
|
||
|
||
- A space is required between an option and its value (for example, **actions= restart**). If the space is omitted, the operation will fail.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
The following examples show how you can use the **sc failure** command:
|
||
|
||
|
||
|
||
```
|
||
|
||
sc failure msftpsvc reset= 30 actions= restart/5000
|
||
|
||
sc failure dfs reset= 60 command= c:\windows\services\restart_dfs.exe actions= run/5000
|
||
|
||
sc failure dfs reset= 60 actions= reboot/30000
|
||
|
||
sc failure dfs reset= 60 reboot= "The Distributed File System service has failed. Because of this, the computer will reboot in 30 seconds." actions= reboot/30000
|
||
|
||
sc failure myservice reset= 3600 reboot= "MyService crashed -- rebooting machine" command= "%windir%\MyServiceRecovery.exe" actions= restart/5000/run/10000/reboot/60000
|
||
|
||
```
|
||
|
||
|
||
|
||
## Additional references
|
||
|
||
|
||
|
||
[Command-Line Syntax Key](cc771080%28v=ws.11%29)
|
||
|
||
## [SEARCH #9] New-ScheduledTaskTrigger -AtStartup -Daily -At -RandomDelay PowerShell site:learn.microsoft.com
|
||
|
||
Web search results for query: "New-ScheduledTaskTrigger -AtStartup -Daily -At -RandomDelay PowerShell site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"Powershell: New-ScheduledTaskTrigger cmdlet with indefinite duration in Windows 10 and windows 2016 server - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/145419/powershell-new-scheduledtasktrigger-cmdlet-with-in"},{"title":"Set-ScheduledTask (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/set-scheduledtask?view=windowsserver2025-ps"},{"title":"Powershell: New-ScheduledTaskTrigger cmdlet AtLogon and Repetition - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/573477/powershell-new-scheduledtasktrigger-cmdlet-atlogon"},{"title":"Set-ClusteredScheduledTask (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/set-clusteredscheduledtask?view=windowsserver2022-ps&viewFallbackFrom=win10-ps"},{"title":"Register-ScheduledTask (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask?view=windowsserver2025-ps"},{"title":"New-ScheduledTaskAction (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskaction?view=windowsserver2025-ps"},{"title":"New-ScheduledTaskSettingsSet (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2025-ps"},{"title":"New-ScheduledTaskPrincipal (ScheduledTasks) | Microsoft Learn","url":"https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps"}]
|
||
|
||
The search results include several Microsoft Learn resources related to the `New-ScheduledTaskTrigger` PowerShell cmdlet and scheduled task management. Here's a summary of what was found:
|
||
|
||
**Key Results:**
|
||
|
||
1. **Microsoft Q&A Discussion** - Shows examples of using `New-ScheduledTaskTrigger` with parameters like `-Once`, `-At`, `-RepetitionInterval`, and `-RepetitionDuration`
|
||
|
||
2. **Set-ScheduledTask Documentation** - Includes an example using `New-ScheduledTaskTrigger` with the `-At 12:00 -Once` parameters
|
||
|
||
3. **AtLogon Trigger Examples** - Demonstrates using `New-ScheduledTaskTrigger -AtLogOn` with repetition settings
|
||
|
||
4. **Register-ScheduledTask Documentation** - Shows creating a time trigger with `New-ScheduledTaskTrigger -At 12:00 -Once`
|
||
|
||
The search results provide practical examples of using `New-ScheduledTaskTrigger` with various trigger types including time-based triggers with the `-At` parameter and repetition intervals. The documentation covers how to use this cmdlet with other scheduled task cmdlets like `Register-ScheduledTask` and `Set-ScheduledTask`.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #10] Write-EventLog New-EventLog not available PowerShell 7 New-WinEvent alternative
|
||
|
||
Web search results for query: "Write-EventLog New-EventLog not available PowerShell 7 New-WinEvent alternative"
|
||
|
||
Links: [{"title":"How to Write to the Windows Event Log Using PowerShell? - SharePoint Diary","url":"https://www.sharepointdiary.com/2022/08/powershell-write-to-event-log.html"},{"title":"How to Write Logs to the Windows Event Viewer from PowerShell/CMD | Windows OS Hub","url":"https://woshub.com/write-logs-event-viewer-powershell-cmd/"},{"title":"PowerShell and the Windows Event Log » cyberfella IT SME","url":"https://www.cyberfella.co.uk/2022/05/16/powershell-and-the-windows-event-log/"},{"title":"PowerShell Windows Event Log: Create Custom Log Entries | Command in Line","url":"https://www.commandinline.com/powershell-write-eventlog-custom/"},{"title":"write eventlog","url":"https://learn.microsoft.com/en-us/powershell/module/Microsoft.powershell.management/write-eventlog?view=powershell-5.1"},{"title":"new eventlog","url":"https://learn.microsoft.com/en-us/previous-versions/powershell/module/microsoft.powershell.management/new-eventlog?view=powershell-5.0"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-us/previous-versions/dd347687(v=technet.10)"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-us/previous-versions//dd315363(v=technet.10)?redirectedfrom=MSDN"},{"title":"This might point you in the right direction:","url":"https://learn.microsoft.com/en-us/answers/questions/593292/how-to-write-windows-event-logs-in-powershell-7"},{"title":"new winevent","url":"https://learn.microsoft.com/en-us/previous-versions/powershell/module/Microsoft.PowerShell.Diagnostics/new-winevent?view=powershell-3.0"}]
|
||
|
||
Based on the search results, here's what you need to know about event logging in PowerShell 7:
|
||
|
||
## Availability in PowerShell 7
|
||
|
||
PowerShell 7 doesn't include Write-EventLog, and New-EventLog is not recognised as a name of a cmdlet in PowerShell 7.
|
||
|
||
## New-WinEvent Alternative
|
||
|
||
In PowerShell Core 7.x, you should use New-WinEvent instead. However, New-WinEvent allows you to write to event log, but only for registered event providers. This cmdlet is primarily designed for Event Tracing for Windows (ETW) and is not a direct replacement for Write-EventLog.
|
||
|
||
## Important Limitations
|
||
|
||
You cannot freely set the log name and entry type or easily create custom sources like the classic cmdlets. Additionally, to use it, you need to register a separate event provider, which can be complicated.
|
||
|
||
## Workaround
|
||
|
||
If you need traditional event logging functionality, use New-WinEvent when you need structured event data or are building a product that ships a proper event manifest. Alternatively, you can import the classic Microsoft.PowerShell.Management module in compatibility mode to use the legacy cmdlets.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #11] Session 0 isolation Windows services interactive desktop site:learn.microsoft.com
|
||
|
||
Web search results for query: "Session 0 isolation Windows services interactive desktop site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"Windows Services | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/hanybarakat/windows-services"},{"title":"Launching an interactive process from Windows Service in Windows Vista and later | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/winsdk/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later"},{"title":"Creating a user-interactive Task Sequence experience | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/cameronk/creating-a-user-interactive-task-sequence-experience"},{"title":"How to launch a process interactively from a Windows Service? | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/winsdk/how-to-launch-a-process-interactively-from-a-windows-service"},{"title":"Interactive Services - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/services/interactive-services"},{"title":"Screen recording from a Windows service which is running under local system account - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/5875437/screen-recording-from-a-windows-service-which-is-r"},{"title":"Services and Session Zero in Vista and Windows Server 2008 | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/brad_rutkowski/services-and-session-zero-in-vista-and-windows-server-2008"},{"title":"Do you still use the MessageBox API in your Windows Service? | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/blogs/yvesdolc/do-you-still-use-the-messagebox-api-in-your-windows-service"},{"title":"We noticed that the Interactive Services Detection service was removed from Windows 10 at version 1803, is this service only removed from Desktop or servers as well? - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/fad0c42f-9d12-4cf6-a54a-2f9cf8731e4f/we-noticed-that-the-interactive-services-detection?forum=windows-all"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653293(v=vs.85)"}]
|
||
|
||
I've successfully performed the web search for your query. Here are the key findings from Microsoft Learn:
|
||
|
||
## Session 0 Isolation and Interactive Desktop
|
||
|
||
In Windows Vista and later versions of Windows, services run in a separate session called Session 0. The Windows Vista operating system mitigates security risk by isolating services in Session 0 and making Session 0 noninteractive.
|
||
|
||
### Historical Context
|
||
|
||
Until Windows Server 2003, services and the first logged on user used to run in the same session, Session 0, and the Window station and desktop of the first logged on user was shared by services running in the same session. However, in Windows Vista, Windows Server 2008, and later versions of Windows, the operating system isolates services in Session 0 and runs applications in other sessions, so services are protected from attacks that originate in application code.
|
||
|
||
### Interactive Desktop Implications
|
||
|
||
Techniques to interact with the user from a service include: displaying a dialog box in the user's session using the WTSSendMessage function, creating a separate hidden GUI application and using the CreateProcessAsUser function to run the application within the context of the interactive user, or designing the GUI application to communicate with the service through interprocess communication.
|
||
|
||
When you update to or install Windows 10 Version 1803 or later or Server 2019, the Interactive Services Detection Service (UI0Detect) will no longer be present, which means you can no longer switch desktop to Session 0.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #12] Windows Fast Startup scheduled task "At startup" trigger does not fire shutdown hibernate
|
||
|
||
Web search results for query: "Windows Fast Startup scheduled task "At startup" trigger does not fire shutdown hibernate"
|
||
|
||
Links: [{"title":"Scheduled \"At Startup\" task that worked in Windows 7 no longer works after upgrade to Windows 10 - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/3254425/scheduled-at-startup-task-that-worked-in-windows-7"},{"title":"Scheduled Tasks with \"Startup\" trigger not firing - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/1180993/scheduled-tasks-with-startup-trigger-not-firing"},{"title":"Turn On or Off Fast Startup in Windows 10 - Windows 10 Help Forums","url":"https://www.tenforums.com/tutorials/4189-turn-off-fast-startup-windows-10-a.html"},{"title":"Why is my Windows pc automatically locking after startup?","url":"https://learn.microsoft.com/en-us/answers/questions/2286178/why-is-my-windows-pc-automatically-locking-after-s"},{"title":"Scheduled Tasks with \"Startup\" trigger not firing","url":"https://learn.microsoft.com/en-gb/answers/questions/1180993/scheduled-tasks-with-startup-trigger-not-firing"},{"title":"fast startup causes system hibernation shutdown fail","url":"https://docs.microsoft.com/pt-br/troubleshoot/windows-client/deployment/fast-startup-causes-system-hibernation-shutdown-fail"},{"title":"windows service not really running after shutdown","url":"https://learn.microsoft.com/en-us/answers/questions/1275681/windows-service-not-really-running-after-shutdown"},{"title":"supporting windows 8 fast startup with group policy","url":"https://learn.microsoft.com/en-us/archive/blogs/keithmayer/supporting-windows-8-fast-startup-with-group-policy"},{"title":"New on Yahoo","url":"https://tech.yahoo.com/computing/articles/why-wish-had-disabled-windows-163120947.html"}]
|
||
|
||
I found relevant search results about Windows Fast Startup and scheduled task issues. Here's what I found:
|
||
|
||
## Key Issue
|
||
|
||
Windows Fast Startup (introduced in Windows 8) is a feature where when enabled, the Windows closes all applications but the system itself goes to hibernation and then wakes up instead of booting from scratch. This behavior is at the root of the problem with "At startup" triggered tasks.
|
||
|
||
## Why "At startup" Tasks Don't Fire
|
||
|
||
When Windows is shutdown but the computer is not powered off and then Windows is started, the task runs at startup. However, when Fast Startup is turned on and user shuts down system, the system goes to hibernation and then wakes up instead of booting from scratch. Since the system is resuming from hibernation rather than performing an actual boot/startup, the "At startup" trigger may not fire as expected.
|
||
|
||
## Solutions
|
||
|
||
The search results indicate several potential workarounds:
|
||
|
||
1. Turning off Fast Startup would resolve the issue by forcing a true system boot instead of hibernation resume.
|
||
|
||
2. Creating a task with a trigger "When a specific event is logged" (selecting log: Microsoft-Windows-Diagnostics-Performance, source - PowerTroubleshooter, Event ID - 1) is an alternative approach.
|
||
|
||
3. Using a scheduled start time (like 2am) with "run task as soon as possible after a scheduled start is missed" is another workaround mentioned.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #13] python win11toast vs windows-toasts vs winotify vs plyer toast notification Windows 11 comparison
|
||
|
||
Web search results for query: "python win11toast vs windows-toasts vs winotify vs plyer toast notification Windows 11 comparison"
|
||
|
||
Links: [{"title":"GitHub - GitHub30/win11toast: Toast notifications for Windows 10 and 11 based on WinRT · GitHub","url":"https://github.com/GitHub30/win11toast"},{"title":"win11toast · PyPI","url":"https://pypi.org/project/win11toast/"},{"title":"Windows-Toasts 1.3.1 documentation","url":"https://windows-toasts.readthedocs.io/"},{"title":"GitHub - DatGuy1/Windows-Toasts: Python library used to send toast notifications on Windows machines · GitHub","url":"https://github.com/DatGuy1/Windows-Toasts"},{"title":"Python: Windows Toast Notifications - Tongere","url":"https://tongere.hashnode.dev/python-windows-toast-notifications"},{"title":"pypi.org","url":"https://pypi.org/project/toasted/0.2.0"},{"title":"pypi.org","url":"https://pypi.org/project/toasted"},{"title":"Windows Toasts","url":"https://pypi.org/project/Windows-Toasts"},{"title":"github.com","url":"https://github.com/ysfchn/toasted"},{"title":"DEV Community","url":"https://dev.to/asjordi/notificaciones-de-windows-con-python-5cdk"}]
|
||
|
||
Based on the search results, here's a comparison of Python toast notification libraries for Windows 11:
|
||
|
||
## Key Libraries
|
||
|
||
**win11toast**
|
||
Toast notifications for Windows 10 and 11. This library supports features like custom audio, progress bars, and click handlers with a straightforward syntax.
|
||
|
||
**windows-toasts**
|
||
A Python library that uses Windows SDK bindings to create and deliver notifications, avoiding workarounds like Powershell hacks. It supports Windows 10 and 11.
|
||
|
||
**winotify**
|
||
Based on the search results, this is a simpler library for creating and showing toast notifications with features like custom icons, audio, and clickable actions.
|
||
|
||
**Plyer**
|
||
For Windows it uses win10toast (an old version of win11toast), while for MacOS and Linux it makes calls directly to the OS to create toasts. This makes it cross-platform but may not be optimal for Windows 11 specifically.
|
||
|
||
## Feature Comparison
|
||
|
||
Toasted (another option) supports all notification elements provided by Windows, such as inputs, selects, buttons, images, and different text styles, offering more advanced capabilities than basic libraries.
|
||
|
||
One user's assessment found that win11toast had simpler syntax and provided all needed features for their use case.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #14] WSL2 systemd cron not running when WSL not started Task Scheduler wsl.exe at logon
|
||
|
||
Web search results for query: "WSL2 systemd cron not running when WSL not started Task Scheduler wsl.exe at logon"
|
||
|
||
Links: [{"title":"Cron will not keep running in background and does not log to cron.log · Issue #9072 · microsoft/WSL","url":"https://github.com/microsoft/WSL/issues/9072"},{"title":"How to Launch Cron Automatically in WSL on Windows 10 and 11","url":"https://www.howtogeek.com/746532/how-to-launch-cron-automatically-in-wsl-on-windows-10-and-11/"},{"title":"WSL cannot be run by scheduled task · Issue #10732 · microsoft/WSL","url":"https://github.com/microsoft/WSL/issues/10732"},{"title":"`cron` on Windows Subsystem for Linux (WSL) - Learn / Linux Shell","url":"https://learn.openwaterfoundation.org/owf-learn-linux-shell/appendix-cron/cron-wsl/cron-wsl/"},{"title":"Use WSL Cron Jobs to Run Windows Scheduled Tasks | pwshtips","url":"https://pwshtips.com/posts/wsl-cron-run-windows-scheduled-tasks/"},{"title":"wsl2 can't run in the background after enabling systemd","url":"https://learn.microsoft.com/en-us/answers/questions/1192206/wsl2-cant-run-in-the-background-after-enabling-sys"}]
|
||
|
||
Based on the search results, here's what I found about this issue:
|
||
|
||
## The Problem
|
||
|
||
Cron inside WSL will not run until the WSL distro starts. WSL doesn't start cron automatically, meaning that your automated tasks aren't getting executed by default. Additionally, if you setup a Task Scheduler event to start the WSL cron service on bootup, the cron does not run automatically.
|
||
|
||
## Solutions
|
||
|
||
The recommended approach is to create a Windows Scheduled Task that starts WSL at boot or at user logon.
|
||
|
||
One modern solution involves creating a PowerShell-based scheduled task that starts the WSL distro and keeps it running:
|
||
|
||
"systemctl start cron; nohup sleep infinity >/dev/null 2>&1" - this command starts the cron service while keeping a lightweight process running so the distro doesn't immediately exit.
|
||
|
||
## Key Consideration for systemd
|
||
|
||
If you're using systemd: WSL can stop when no Linux processes are running. If cron is running under systemd, that may be enough. If your distro still exits, keep one harmless long-running process active.
|
||
|
||
The key issue is that you need a process running that's a child of the Microsoft init (like an interactive shell) to keep WSL from idle-terminating.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #15] Task Scheduler event IDs 101 103 203 Microsoft-Windows-TaskScheduler/Operational enable history wevtutil
|
||
|
||
Web search results for query: "Task Scheduler event IDs 101 103 203 Microsoft-Windows-TaskScheduler/Operational enable history wevtutil"
|
||
|
||
Links: [{"title":"TaskScheduler/TaskService/TaskEvent.cs at master · dahall/TaskScheduler","url":"https://github.com/dahall/TaskScheduler/blob/master/TaskService/TaskEvent.cs"},{"title":"Schedule not working well on Task Scheduler - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/472121/schedule-not-working-well-on-task-scheduler"},{"title":"EventTracker KB --Event Id: 101 Source: Microsoft-Windows-TaskScheduler","url":"https://kb.eventtracker.com/evtpass/evtpages/EventId_101_Microsoft-Windows-TaskScheduler_61809.asp"},{"title":"Monitor Task Scheduler? - KS-Soft","url":"https://www.ks-soft.net/phpBB/viewtopic.php?t=8251"},{"title":"Fix Task Scheduler failed to start, Event ID 101","url":"https://www.thewindowsclub.com/fix-task-scheduler-failed-to-start-event-id-101"},{"title":"Event ID 101 Source Microsoft-Windows-TaskScheduler/Operational","url":"https://www.myeventlog.com/search/show/855"},{"title":"ETW - Windows Scheduled Tasks | artifacts.help","url":"https://artefacts.help/windows_etw_scheduled_task.html"},{"title":"Task Scheduler Event IDs | mnaoumov.NET - WordPress.com","url":"https://mnaoumov.wordpress.com/2014/05/15/task-scheduler-event-ids/"},{"title":"Reference The Event That Triggered Your Task","url":"https://learn.microsoft.com/it-it/archive/blogs/otto/reference-the-event-that-triggered-your-task"},{"title":"Task Properties","url":"https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc775003(v=ws.10)"}]
|
||
|
||
Based on the search results, here's what I found about Task Scheduler event IDs and the Microsoft-Windows-TaskScheduler/Operational channel:
|
||
|
||
## Event ID Meanings
|
||
|
||
Event ID 101 is normally logged when a task fails to start. Event ID 102 is normally logged when a task completes successfully.
|
||
|
||
Event ID 107 is normally logged when a task is launched due to a trigger.
|
||
|
||
Regarding event ID 203, the search results mention it as part of error monitoring—default HostMonitor test templates include "Event: TaskSchedulerError" test which checks events with ID 111, 331, 203, 327, 329, 202.
|
||
|
||
## Microsoft-Windows-TaskScheduler/Operational Channel
|
||
|
||
The Microsoft-Windows-TaskScheduler/Operational channel is not enabled by default. The channel logs events: 100, 102, 103, 106, 107, 108, 110, 118, 119, 129, 140, 141, 200, 201.
|
||
|
||
## Enabling History
|
||
|
||
You can enable task scheduler history and click the History tab to view the task's history.
|
||
|
||
The search results don't provide specific details about using `wevtutil` to enable this channel, though it's a common tool for managing Windows Event Log channels from the command line.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #16] Uptime Kuma push monitor heartbeat URL dead man switch PowerShell
|
||
|
||
Web search results for query: "Uptime Kuma push monitor heartbeat URL dead man switch PowerShell"
|
||
|
||
Links: [{"title":"Uptime Kuma - Configure Push Monitor | Programster's Blog","url":"https://blog.programster.org/uptime-kuma-configure-push-monitor"},{"title":"GitHub - jmclaren7/uptime-kuma-push: PowerShell script to leverage UptimeKuma's push feature with local uptime tests · GitHub","url":"https://github.com/jmclaren7/uptime-kuma-push"},{"title":"Monitoring sites and backups with Uptime Kuma (push + ping) | Symfolidity","url":"https://symfolidity.com/en/articles/monitoring-sites-and-backups-with-uptime-kuma/"},{"title":"Self-Host Uptime Kuma on a VPS for Free Status Monitoring | Blog | RDP.sh","url":"https://rdp.sh/blog/self-host-uptime-kuma-on-a-vps-for-free-status-monitoring"},{"title":"The Dead Man’s Switch: Foolproof Backup Monitoring with Duplicati and Uptime Kuma | tywer.dev","url":"https://tywer.dev/the-dead-mans-switch-foolproof-backup-monitoring-with-duplicati-and-uptime-kuma"},{"title":"Using Push heartbeat monitoring in Uptime Kuma | Wiki SmartxTechnologies","url":"https://wiki.smartxtechnologies.com/uptime-kuma/monitor-push-heartbeat"},{"title":"Self-Hosted Cron Job Monitoring: Healthchecks vs Uptime Kuma vs Prometheus 2026 | Pi Stack","url":"https://www.pistack.xyz/posts/self-hosted-cron-job-monitoring-healthchecks-uptime-kuma-prometheus-guide-2026/"},{"title":"Uptime Kuma: The Monitoring Tool That Actually Makes Sense","url":"https://dataengineeringtoolkit.substack.com/p/uptime-kuma-the-monitoring-tool-that"},{"title":"uptime kuma pushr","url":"https://github.com/JPVenson/uptime-kuma-pushr"}]
|
||
|
||
Based on the search results, here's what I found about Uptime Kuma's push monitor heartbeat feature with PowerShell:
|
||
|
||
## Push Monitor Overview
|
||
|
||
Push monitoring flips normal monitoring logic: instead of Uptime Kuma checking your service, your service sends a heartbeat to Uptime Kuma. If the heartbeat stops arriving within a defined timeout, the monitor is marked down and notifications fire.
|
||
|
||
## Dead Man's Switch
|
||
|
||
This is called a dead man's switch, by analogy with the train brake that engages automatically if the driver lets go: the absence of signal is the alert signal. Uptime Kuma's Push monitors are a free dead-man's-switch for backups and scheduled tasks.
|
||
|
||
## Setting Up a Push Monitor
|
||
|
||
Click on Monitor Type and select Push from the dropdown. Set a heartbeat interval. If your service does not "check in" within this time period of its last "check in", then Uptime Kuma will assume the service is down and send you an alert.
|
||
|
||
## Using PowerShell to Send Heartbeats
|
||
|
||
You can send heartbeat from Windows using PowerShell Invoke-WebRequest -Uri "URL" or wget, curl.exe, or any HTTP client.
|
||
|
||
## Push URL Format
|
||
|
||
When setting the type use "Push" and you will get a "Push Url" that looks like this: "https://DOMAIN/api/push/CODE?status=up&msg=OK&ping=".
|
||
|
||
## Practical Application
|
||
|
||
This is a PowerShell script that you can use with Uptime Kuma's push feature for monitoring servers on a network Uptime Kuma can't communicate with. For example, your Uptime Kuma server is in the cloud but you want to monitor servers and devices on your local network.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [FETCH #5] https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasktrigger?view=windowsserver2025-ps
|
||
**ASK:** List the syntax parameter sets (AtStartup, AtLogOn, Daily, Weekly, Once) and all parameters with their meanings, especially -AtStartup, -Daily, -DaysInterval, -At, -RandomDelay, -RepetitionInterval, -RepetitionDuration, -User. Include the examples verbatim.
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
defaultMoniker: windowsserver2025-ps
|
||
versioningType: Ranged
|
||
title: New-ScheduledTaskTrigger (ScheduledTasks) | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasktrigger?view=windowsserver2025-ps
|
||
config_moniker_range: WindowsServer2025-ps
|
||
uid: ScheduledTasks.New-ScheduledTaskTrigger
|
||
module: ScheduledTasks
|
||
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/windows/get-started
|
||
author: robinharwood
|
||
breadcrumb_path: /powershell/windows/bread/toc.json
|
||
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
||
feedback_system: Standard
|
||
manager: eliotgra
|
||
ms.author: roharwoo
|
||
ms.devlang: powershell
|
||
ms.service: windows-11
|
||
ms.topic: reference
|
||
uhfHeaderId: MSDocsHeader-M365-IT
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56754133-c3c3-4a9f-af19-71bdbe19fccf
|
||
document type: cmdlet
|
||
external help file: PS_ScheduledTask_v1.0.cdxml-help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/scheduledtasks/new-scheduledtasktrigger?view=windowsserver2025-ps&wt.mc_id=ps-gethelp
|
||
Module Name: ScheduledTasks
|
||
ms.date: 2016-12-20T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: e92d735a-14e6-a57c-31e0-0deed4386b01
|
||
document_version_independent_id: 28a6ea5e-cd82-e1bd-4b8c-9500cbb9a395
|
||
updated_at: 2025-05-14T22:44:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/live/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskTrigger.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/0ef3f225d29e26d1cf3119f37dfff70bb6165746/docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskTrigger.md
|
||
git_commit_id: 0ef3f225d29e26d1cf3119f37dfff70bb6165746
|
||
default_moniker: windowsserver2025-ps
|
||
site_name: Docs
|
||
depot_name: TechNet.windows-powershell
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../windowsserver2025-ps/toc.json
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
asset_id: module/scheduledtasks/new-scheduledtasktrigger
|
||
moniker_range_name: ffb05b7b47577225af7c7b6a20151268
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
item_type: Content
|
||
source_path: docset/winserver2025-ps/ScheduledTasks/New-ScheduledTaskTrigger.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 75c34315-4906-31ad-e2de-3a051ca5fe4a
|
||
---
|
||
|
||
# New-ScheduledTaskTrigger
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [ScheduledTasks Module](./)
|
||
|
||
|
||
|
||
Creates a scheduled task trigger object.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### Once (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskTrigger
|
||
|
||
-At <DateTime>
|
||
|
||
[-RandomDelay <TimeSpan>]
|
||
|
||
[-Once]
|
||
|
||
[-RepetitionDuration <TimeSpan>]
|
||
|
||
[-RepetitionInterval <TimeSpan>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Daily
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskTrigger
|
||
|
||
-At <DateTime>
|
||
|
||
[-Daily]
|
||
|
||
[-DaysInterval <UInt32>]
|
||
|
||
[-RandomDelay <TimeSpan>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Weekly
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskTrigger
|
||
|
||
-At <DateTime>
|
||
|
||
[-RandomDelay <TimeSpan>]
|
||
|
||
[-DaysOfWeek <DayOfWeek[]>]
|
||
|
||
[-Weekly]
|
||
|
||
[-WeeksInterval <UInt32>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Startup
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskTrigger
|
||
|
||
[-RandomDelay <TimeSpan>]
|
||
|
||
[-AtStartup]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Logon
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-ScheduledTaskTrigger
|
||
|
||
[-RandomDelay <TimeSpan>]
|
||
|
||
[-AtLogOn]
|
||
|
||
[-User <String>]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
The **New-ScheduledTaskTrigger** cmdlet creates and returns a new scheduled task trigger object.
|
||
|
||
|
||
|
||
You can use a time-based trigger or an event-based trigger to start a task. Time-based triggers include starting a task at a specific time or starting a task multiple times on a daily or weekly schedule. Event-based triggers include starting a task when the system starts up or when a user logs on to the computer. Each task can contain one or more triggers, which means there are many ways that you can start a task. If a task has multiple triggers, Task Scheduler starts the task when any of the triggers occur.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1: Register a scheduled task that starts a task once
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
PS C:\>$Stt = New-ScheduledTaskTrigger -Once -At 3am
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that starts once.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable. The second command creates a scheduled task trigger that starts the task once at 3:00 A.M and assigns the **ScheduledTaskTrigger** object to the $Stt variable. The third command registers the scheduled task Task01 to run the task action named Cmd once at 3:00 A.M.
|
||
|
||
|
||
|
||
### Example 2: Register a scheduled task that starts every day
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
PS C:\>$Stt = New-ScheduledTaskTrigger -Daily -At 3am
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that starts every day.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable. The second command creates a scheduled task trigger that starts every day at 3:00 A.M and assigns the **ScheduledTaskTrigger** object to the $Stt variable. The third command registers the scheduled task Task01 to run the task action named Cmd every day at 3:00 A.M.
|
||
|
||
|
||
|
||
### Example 3: Register a scheduled task that starts every 3 days
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
PS C:\>$Stt = New-ScheduledTaskTrigger -Daily -DaysInterval 3 -At 3am
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that starts every 3 days.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable. The second command creates a scheduled task trigger that starts every 3 days at 3:00 A.M and assigns the **ScheduledTaskTrigger** object to the $Stt variable. The third command registers the scheduled task Task01 to run the task action named cmd every 3 days at 3:00 A.M.
|
||
|
||
|
||
|
||
### Example 4: Register a scheduled task that starts every-other week
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
PS C:\>$Stt = New-ScheduledTaskTrigger -Weekly -WeeksInterval 2 -DaysOfWeek Sunday -At 3am
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that starts every other week.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable. The second command creates a scheduled task trigger that starts every other Sunday at 3:00 A.M and assigns the **ScheduledTaskTrigger** object to the $Stt variable. The third command registers the scheduled task Task01 to run the task action named Cmd every other Sunday at 3:00 A.M.
|
||
|
||
|
||
|
||
### Example 5: Register a scheduled task that starts when a user logs on
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"
|
||
|
||
PS C:\>$Stt = New-ScheduledTaskTrigger -AtLogon
|
||
|
||
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Trigger $Stt
|
||
|
||
```
|
||
|
||
|
||
|
||
This example registers a scheduled task that starts when a user logs on.
|
||
|
||
|
||
|
||
The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable. The second command creates a scheduled task trigger that starts when a user logs on, and assigns the **ScheduledTaskTrigger** object to the $Stt variable. The third command registers the scheduled task Task01 to run the task action named Cmd when a user logs on.
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -AsJob
|
||
|
||
|
||
|
||
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -At
|
||
|
||
|
||
|
||
Specifies a date and time to trigger the task. This parameter is valid for calendar-based triggers (Once, Daily, Weekly).
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | DateTime |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Once
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Daily
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Weekly
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -AtLogOn
|
||
|
||
|
||
|
||
Indicates that a trigger starts a task when a user logs on.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Logon
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -AtStartup
|
||
|
||
|
||
|
||
Indicates that a trigger starts a task when the system is started.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Startup
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -CimSession
|
||
|
||
|
||
|
||
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a Common Information Model (CIM) session object that represents a connection to a local computer or a remote computer, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimSession[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | Session |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Daily
|
||
|
||
|
||
|
||
Indicates that a trigger starts a task on a recurring daily schedule.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Daily
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -DaysInterval
|
||
|
||
|
||
|
||
Specifies the interval between the days in the schedule. An interval of 1 produces a daily schedule. An interval of 2 produces an every-other day schedule.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | UInt32 |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Daily
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -DaysOfWeek
|
||
|
||
|
||
|
||
Specifies an array of the days of the week on which Task Scheduler runs the task.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | DayOfWeek[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Weekly
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Once
|
||
|
||
|
||
|
||
Indicates that a trigger starts a task once at a time specified in the *At* parameter.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Once
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -RandomDelay
|
||
|
||
|
||
|
||
Specifies a random amount of time to delay the start time of the trigger.
|
||
…[truncated 5253 chars]
|
||
|
||
## [FETCH #6] https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask?view=windowsserver2025-ps
|
||
**ASK:** List all parameter sets and parameters (-Action, -Trigger, -Settings, -Principal, -User, -Password, -RunLevel, -TaskName, -TaskPath, -Xml, -Description, -Force, -InputObject). Quote the descriptions of -User, -Password, -RunLevel and -Xml, and give the examples verbatim.
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
defaultMoniker: windowsserver2025-ps
|
||
versioningType: Ranged
|
||
title: Register-ScheduledTask (ScheduledTasks) | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask?view=windowsserver2025-ps
|
||
config_moniker_range: WindowsServer2025-ps
|
||
uid: ScheduledTasks.Register-ScheduledTask
|
||
module: ScheduledTasks
|
||
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/windows/get-started
|
||
author: robinharwood
|
||
breadcrumb_path: /powershell/windows/bread/toc.json
|
||
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
||
feedback_system: Standard
|
||
manager: eliotgra
|
||
ms.author: roharwoo
|
||
ms.devlang: powershell
|
||
ms.service: windows-11
|
||
ms.topic: reference
|
||
uhfHeaderId: MSDocsHeader-M365-IT
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56754133-c3c3-4a9f-af19-71bdbe19fccf
|
||
document type: cmdlet
|
||
external help file: PS_ScheduledTask_v1.0.cdxml-help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/scheduledtasks/register-scheduledtask?view=windowsserver2025-ps&wt.mc_id=ps-gethelp
|
||
Module Name: ScheduledTasks
|
||
ms.date: 2016-12-20T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 221cc21e-77e7-967e-821b-74e3d6549edd
|
||
document_version_independent_id: b9cfe0d7-e507-8868-2a39-ff694cc53afc
|
||
updated_at: 2025-05-14T22:44:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/live/docset/winserver2025-ps/ScheduledTasks/Register-ScheduledTask.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/0ef3f225d29e26d1cf3119f37dfff70bb6165746/docset/winserver2025-ps/ScheduledTasks/Register-ScheduledTask.md
|
||
git_commit_id: 0ef3f225d29e26d1cf3119f37dfff70bb6165746
|
||
default_moniker: windowsserver2025-ps
|
||
site_name: Docs
|
||
depot_name: TechNet.windows-powershell
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../windowsserver2025-ps/toc.json
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
asset_id: module/scheduledtasks/register-scheduledtask
|
||
moniker_range_name: ffb05b7b47577225af7c7b6a20151268
|
||
monikers:
|
||
- windowsserver2025-ps
|
||
item_type: Content
|
||
source_path: docset/winserver2025-ps/ScheduledTasks/Register-ScheduledTask.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: dc26f37b-95d1-1184-0c53-35087521caf6
|
||
---
|
||
|
||
# Register-ScheduledTask
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [ScheduledTasks Module](./)
|
||
|
||
|
||
|
||
Registers a scheduled task definition on a local computer.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### User (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
Register-ScheduledTask
|
||
|
||
[[-Password] <String>]
|
||
|
||
[[-User] <String>]
|
||
|
||
[-TaskName] <String>
|
||
|
||
[[-TaskPath] <String>]
|
||
|
||
[-Action] <CimInstance[]>
|
||
|
||
[[-Description] <String>]
|
||
|
||
[[-Settings] <CimInstance>]
|
||
|
||
[[-Trigger] <CimInstance[]>]
|
||
|
||
[[-RunLevel] <RunLevelEnum>]
|
||
|
||
[-Force]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Xml
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
Register-ScheduledTask
|
||
|
||
[[-Password] <String>]
|
||
|
||
[[-User] <String>]
|
||
|
||
[-TaskName] <String>
|
||
|
||
[[-TaskPath] <String>]
|
||
|
||
[-Xml] <String>
|
||
|
||
[-Force]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Principal
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
Register-ScheduledTask
|
||
|
||
[-TaskName] <String>
|
||
|
||
[[-TaskPath] <String>]
|
||
|
||
[[-Principal] <CimInstance>]
|
||
|
||
[-Action] <CimInstance[]>
|
||
|
||
[[-Description] <String>]
|
||
|
||
[[-Settings] <CimInstance>]
|
||
|
||
[[-Trigger] <CimInstance[]>]
|
||
|
||
[-Force]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Object
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
Register-ScheduledTask
|
||
|
||
[-InputObject] <CimInstance>
|
||
|
||
[[-Password] <String>]
|
||
|
||
[[-User] <String>]
|
||
|
||
[[-TaskName] <String>]
|
||
|
||
[[-TaskPath] <String>]
|
||
|
||
[-Force]
|
||
|
||
[-CimSession <CimSession[]>]
|
||
|
||
[-ThrottleLimit <Int32>]
|
||
|
||
[-AsJob]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
The **Register-ScheduledTask** cmdlet registers a scheduled task definition on a local computer.
|
||
|
||
|
||
|
||
You can register a task to run executable files (`.exe` and `.com`), batch files (`.bat` and `.cmd`), or any registered file type. However, this cmdlet does not check whether the file you intend it to run is compatible with your version, edition, or platform specialization of Windows.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1: Register a scheduled task
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\> $Time = New-ScheduledTaskTrigger -At 12:00 -Once
|
||
|
||
PS C:\> $User = "Contoso\Administrator"
|
||
|
||
PS C:\> $PS = New-ScheduledTaskAction -Execute "PowerShell.exe"
|
||
|
||
PS C:\> Register-ScheduledTask -TaskName "SoftwareScan" -Trigger $Time -User $User -Action $PS
|
||
|
||
```
|
||
|
||
|
||
|
||
In this example, the set of commands uses cmdlets and variables to define and register a scheduled task.
|
||
|
||
|
||
|
||
The first command uses the New-ScheduledTaskTrigger cmdlet to assign a time trigger to the $Time variable.
|
||
|
||
|
||
|
||
The second command assigns the $User variable the name of the user account in the context of which the task runs (Contoso\Administrator).
|
||
|
||
|
||
|
||
The third command assigns the $PS variable to PowerShell.exe. This variable is used to define a task action.
|
||
|
||
|
||
|
||
The fourth command registers a scheduled task that is named SoftwareScan in the root folder. The registered task uses the pre-created action and trigger values that are specified by the $Action and $User variables.
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -Action
|
||
|
||
|
||
|
||
Specifies an array of one or more work items for the task to run. If you specify multiple actions, the computer runs them in order. You can specify up to 32 actions.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimInstance[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Principal
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -AsJob
|
||
|
||
|
||
|
||
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -CimSession
|
||
|
||
|
||
|
||
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a [New-CimSession](/en-us/powershell/module/cimcmdlets/new-cimsession) or [Get-CimSession](/en-us/powershell/module/cimcmdlets/get-cimsession) cmdlet. The default is the current session on the local computer.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimSession[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | Session |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Description
|
||
|
||
|
||
|
||
Briefly describes the task.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 8 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Principal
|
||
|
||
|
||
|
||
| Position: | 8 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Force
|
||
|
||
|
||
|
||
Instructs the cmdlet to perform the operation without prompting for confirmation.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | SwitchParameter |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -InputObject
|
||
|
||
|
||
|
||
Specifies the input object that is used in a pipeline command.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimInstance |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Object
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | True |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Password
|
||
|
||
|
||
|
||
Specifies a password for the user account in the context of which the task runs. The password is ignored for the well-known system accounts.
|
||
|
||
|
||
|
||
Well-known accounts are: NT AUTHORITY\SYSTEM, NT AUTHORITY\LOCALSERVICE, NT AUTHORITY\NETWORKSERVICE, and the well-known security identifiers (SIDs) for all three accounts.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Xml
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Object
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Principal
|
||
|
||
|
||
|
||
Specifies the security context in which a task is run.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimInstance |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
Principal
|
||
|
||
|
||
|
||
| Position: | 5 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -RunLevel
|
||
|
||
|
||
|
||
Specifies the required privilege level to run tasks that are associated with the principal.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | RunLevelEnum |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | Limited, Highest |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 7 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Settings
|
||
|
||
|
||
|
||
Specifies a configuration that the Task Scheduler service uses to determine how to run a task.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | CimInstance |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Principal
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -TaskName
|
||
|
||
|
||
|
||
Specifies the name of a scheduled task.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
User
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Xml
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
Principal
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -TaskPath
|
||
|
||
|
||
|
||
Specifies an array of one or more paths for scheduled tasks in Task Scheduler namespace. You can use **"\*"** for a wildcard character query. You can use **\**\* for the root folder. To specify a full TaskPath you need to include the leading and trailing **\**. If you do not specify a path, the cmdlet uses the root folder.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | String |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 1 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ThrottleLimit
|
||
|
||
|
||
|
||
Specifies the maximum number of concurrent operations tha
|
||
…[truncated 4202 chars]
|
||
|
||
## [FETCH #7] https://learn.microsoft.com/en-us/windows/win32/taskschd/principal-logontype
|
||
**ASK:** Quote the full table of TASK_LOGON_TYPE values and their descriptions (TASK_LOGON_NONE, TASK_LOGON_PASSWORD, TASK_LOGON_S4U, TASK_LOGON_INTERACTIVE_TOKEN, TASK_LOGON_GROUP, TASK_LOGON_SERVICE_ACCOUNT, TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD) and any remarks about network access / encrypted files for S4U.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Principal.LogonType property - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/principal-logontype
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: For scripting, gets or sets the security logon method that is required to run the tasks that are associated with the principal.
|
||
ms.assetid: ac6fd7a1-00ef-4478-920f-de391a5a2c8c
|
||
keywords:
|
||
- LogonType property Task Scheduler
|
||
- LogonType property Task Scheduler , Principal object
|
||
- Principal object Task Scheduler , LogonType property
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- Principal.LogonType
|
||
api_location:
|
||
- taskschd.dll
|
||
api_type:
|
||
- COM
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: a5cc612e-6d55-80ce-ec42-dbd9c1ecdfdc
|
||
document_version_independent_id: df58e92a-6ee2-7919-7e17-fd43d5bd8716
|
||
updated_at: 2021-08-25T22:31:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/principal-logontype.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/f2e72219630acfaf2ab6e0d17f8ae7dbc841f1f0/desktop-src/TaskSchd/principal-logontype.md
|
||
git_commit_id: f2e72219630acfaf2ab6e0d17f8ae7dbc841f1f0
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 347
|
||
asset_id: taskschd/principal-logontype
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/principal-logontype.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: d562f16d-b6cf-24f6-e29a-49325cedad4f
|
||
---
|
||
|
||
# Principal.LogonType property - Win32 apps | Microsoft Learn
|
||
|
||
For scripting, gets or sets the security logon method that is required to run the tasks that are associated with the principal.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
```VB
|
||
|
||
Principal.LogonType As Integer
|
||
|
||
```
|
||
|
||
|
||
|
||
## Property value
|
||
|
||
|
||
|
||
Set to one of the following [**TASK\_LOGON TYPE**](/en-us/windows/desktop/api/taskschd/ne-taskschd-task_logon_type) enumeration constants.
|
||
|
||
|
||
|
||
| Value | Meaning |
|
||
|
||
| --- | --- |
|
||
|
||
| - **TASK\_LOGON\_NONE**<br>- 0 | The logon method is not specified. Used for non-NT credentials. |
|
||
|
||
| - **TASK\_LOGON\_PASSWORD**<br>- 1 | Use a password for logging on the user. The password must be supplied at registration time. |
|
||
|
||
| - **TASK\_LOGON\_S4U**<br>- 2 | Use an existing interactive token to run a task. The user must log on using a service for user (S4U) logon. When an S4U logon is used, no password is stored by the system and there is no access to either the network or encrypted files. |
|
||
|
||
| - **TASK\_LOGON\_INTERACTIVE\_TOKEN**<br>- 3 | User must already be logged on. The task will be run only in an existing interactive session. |
|
||
|
||
| - **TASK\_LOGON\_GROUP**<br>- 4 | Group activation. The userId field specifies the group. |
|
||
|
||
| - **TASK\_LOGON\_SERVICE\_ACCOUNT**<br>- 5 | Indicates that a Local System, Local Service, or Network Service account is being used as a security context to run the task. |
|
||
|
||
| - **TASK\_LOGON\_INTERACTIVE\_TOKEN\_OR\_PASSWORD**<br>- 6 | First use the interactive token. If the user is not logged on (no interactive token is available), then the password is used. The password must be specified when a task is registered. This flag is not recommended for new tasks because it is less reliable than TASK\_LOGON\_PASSWORD. |
|
||
|
||
|
||
|
||
## Remarks
|
||
|
||
|
||
|
||
This property is valid only when a user identifier is specified by the [**UserId**](principal-userid) property.
|
||
|
||
|
||
|
||
When reading or writing XML for a task, the logon type is specified in the [**<LogonType>**](taskschedulerschema-logontype-principaltype-element) element of the Task Scheduler schema.
|
||
|
||
|
||
|
||
For a task, that contains a message box action, the message box will be displayed if the task is activated and the task has an interactive logon type. To set the task logon type to interactive, specify 3 (**TASK\_LOGON\_INTERACTIVE\_TOKEN**) or 4 (**TASK\_LOGON\_GROUP**) in the **LogonType** property of the task principal, or in the *logonType* parameter of [**TaskFolder.RegisterTask**](taskfolder-registertask) or [**TaskFolder.RegisterTaskDefinition**](taskfolder-registertaskdefinition).
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
| Type library | - Taskschd.tlb |
|
||
|
||
| DLL | - Taskschd.dll |
|
||
|
||
## [FETCH #8] https://learn.microsoft.com/en-us/windows/win32/services/interactive-services
|
||
**ASK:** Summarize what the page says about Session 0, why services cannot interact with the desktop, which techniques are recommended (WTSSendMessage, CreateProcessAsUser, IPC), and any statement about SERVICE_INTERACTIVE_PROCESS / NoInteractiveServices being deprecated or unsupported.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Interactive Services - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/services/interactive-services
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: system-services
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Typically, services are console applications that are designed to run unattended without a graphical user interface (GUI).
|
||
ms.assetid: 3d6e090a-00b1-47d8-a4fb-620f3db8ba9c
|
||
ms.topic: concept-article
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 64c0438c-888c-ca46-0397-fbbf4c86eab2
|
||
document_version_independent_id: 9174f963-59f9-1872-0125-633d6d5f5d49
|
||
updated_at: 2025-04-15T10:05:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/Services/interactive-services.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/70d815fc0f0d0d72460e6f4f96ee6906ce88a20d/desktop-src/Services/interactive-services.md
|
||
git_commit_id: 70d815fc0f0d0d72460e6f4f96ee6906ce88a20d
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 679
|
||
asset_id: services/interactive-services
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/Services/interactive-services.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/540ac133-a371-4dbb-8f94-28d6cc77a70b
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/60bfc045-f127-4841-9d00-ea35495a5800
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
platformId: 58147440-082c-27ce-3e73-1265c029db9e
|
||
---
|
||
|
||
# Interactive Services - Win32 apps | Microsoft Learn
|
||
|
||
Typically, services are console applications that are designed to run unattended without a graphical user interface (GUI). However, some services may require occasional interaction with a user. This page discusses the best ways to interact with the user from a service.
|
||
|
||
|
||
|
||
Important
|
||
|
||
|
||
|
||
Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.
|
||
|
||
|
||
|
||
## Interacting with a User from a Service Indirectly
|
||
|
||
|
||
|
||
You can use the following techniques to interact with the user from a service on all supported versions of Windows:
|
||
|
||
|
||
|
||
- Display a dialog box in the user's session using the [**WTSSendMessage**](/en-us/windows/desktop/api/wtsapi32/nf-wtsapi32-wtssendmessagea) function.
|
||
|
||
- Create a separate hidden GUI application and use the [**CreateProcessAsUser**](/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessasusera) function to run the application within the context of the interactive user. Design the GUI application to communicate with the service through some method of interprocess communication (IPC), for example, named pipes. The service communicates with the GUI application to tell it when to display the GUI. The application communicates the results of the user interaction back to the service so that the service can take the appropriate action. Note that IPC can expose your service interfaces over the network unless you use an appropriate access control list (ACL).
|
||
|
||
|
||
|
||
If this service runs on a multiuser system, add the application to the following key so that it is run in each session: **HKEY\_LOCAL\_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run**. If the application uses named pipes for IPC, the server can distinguish between multiple user processes by giving each pipe a unique name based on the session ID.
|
||
|
||
|
||
|
||
The following technique is also available for Windows Server 2003 and Windows XP:
|
||
|
||
|
||
|
||
- Display a message box by calling the [**MessageBox**](/en-us/windows/win32/api/winuser/nf-winuser-messagebox) function with **MB\_SERVICE\_NOTIFICATION**. This is recommended for displaying simple status messages. Do not call **MessageBox** during service initialization or from the [**HandlerEx**](/en-us/windows/desktop/api/WinSvc/nc-winsvc-lphandler_function_ex) routine, unless you call it from a separate thread, so that you return to the SCM in a timely manner.
|
||
|
||
|
||
|
||
## Using an Interactive Service
|
||
|
||
|
||
|
||
By default, services use a noninteractive [window station](/en-us/windows/desktop/winstation/window-stations) and cannot interact with the user. However, an *interactive service* can display a user interface and receive user input.
|
||
|
||
|
||
|
||
Caution
|
||
|
||
|
||
|
||
Services running in an elevated security context, such as the LocalSystem account, should not create a window on the interactive desktop because any other application that is running on the interactive desktop can interact with this window. This exposes the service to any application that a logged-on user executes. Also, services that are running as LocalSystem should not access the interactive desktop by calling the [**OpenWindowStation**](/en-us/windows/desktop/api/winuser/nf-winuser-openwindowstationa) or [**GetThreadDesktop**](/en-us/windows/desktop/api/winuser/nf-winuser-getthreaddesktop) function.
|
||
|
||
|
||
|
||
To create an interactive service, do the following when calling the [**CreateService**](/en-us/windows/desktop/api/Winsvc/nf-winsvc-createservicea) function:
|
||
|
||
|
||
|
||
1. Specify NULL for the *lpServiceStartName* parameter to run the service in the context of the [LocalSystem account](localsystem-account).
|
||
|
||
2. Specify the **SERVICE\_INTERACTIVE\_PROCESS** flag.
|
||
|
||
|
||
|
||
To determine whether a service is running as an interactive service, call the [**GetProcessWindowStation**](/en-us/windows/desktop/api/winuser/nf-winuser-getprocesswindowstation) function to retrieve a handle to the window station, and the [**GetUserObjectInformation**](/en-us/windows/desktop/api/winuser/nf-winuser-getuserobjectinformationa) function to test whether the window station has the **WSF\_VISIBLE** attribute.
|
||
|
||
|
||
|
||
However, note that the following registry key contains a value, **NoInteractiveServices**, that controls the effect of SERVICE\_INTERACTIVE\_PROCESS:
|
||
|
||
|
||
|
||
**HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Windows**
|
||
|
||
|
||
|
||
The **NoInteractiveServices** value defaults to 1, which means that no service is allowed to run interactively, regardless of whether it has **SERVICE\_INTERACTIVE\_PROCESS**. When **NoInteractiveServices** is set to a 0, services with **SERVICE\_INTERACTIVE\_PROCESS** are allowed to run interactively.
|
||
|
||
|
||
|
||
**Windows 7, Windows Server 2008 R2, Windows XP and Windows Server 2003:** The **NoInteractiveServices** value defaults to 0, which means that services with **SERVICE\_INTERACTIVE\_PROCESS** are allowed to run interactively. When **NoInteractiveServices** is set to a nonzero value, no service started thereafter is allowed to run interactively, regardless of whether it has **SERVICE\_INTERACTIVE\_PROCESS**.
|
||
|
||
|
||
|
||
Important
|
||
|
||
|
||
|
||
All services run in Terminal Services session 0. Therefore, if an interactive service displays a user interface, it is visible only to the user who connected to session 0. Because there is no way to guarantee that the interactive user is connected to session 0, do not configure a service to run as an interactive service under Terminal Services or on a system that supports fast user switching (fast user switching is implemented using Terminal Services).
|
||
|
||
## [FETCH #9] https://github.com/Windos/BurntToast
|
||
**ASK:** Summarize: current version, install command, supported PowerShell versions (5.1 and 7?), Windows versions, the main cmdlets (New-BurntToastNotification, New-BTButton, New-BTAction, New-BTHeader, Submit-BTNotification, New-BTText, New-BTVisual, New-BTBinding, New-BTContent), the -Button / -Header / -AppLogo parameters, and any notes about v1.0 breaking changes or protocol activation. Also any note
|
||
…[truncated 56 chars]
|
||
|
||
# BurntToast Summary
|
||
|
||
## Current Version & Installation
|
||
Version 1.1.0 is available. Install via PowerShell Gallery with: `Install-Module -Name BurntToast`. Chocolatey installation is also supported.
|
||
|
||
## Supported Environments
|
||
BurntToast targets "Windows 10 and Windows Server 2019 and above." The documentation doesn't specify PowerShell version requirements explicitly, though it mentions enabling features "on all supported versions of PowerShell, including Windows PowerShell" and notes that certain event handling requires "PowerShell 7.1+."
|
||
|
||
## Core Cmdlets
|
||
Key cmdlets include: `New-BurntToastNotification`, `New-BTButton`, `New-BTAction`, `New-BTHeader`, `Submit-BTNotification`, `New-BTText`, `New-BTVisual`, `New-BTBinding`, and `New-BTContent`.
|
||
|
||
## Key Parameters
|
||
The module supports `-Button`, `-Header`, and `-AppLogo` parameters for notification customization. Version 1.1.0 added "support for Important Notifications using the Urgent switch" and button color configuration.
|
||
|
||
## Breaking Changes (v1.0.0)
|
||
Significant removals include custom audio path support, AppId customization, and shoulder tap notifications. The update introduced Windows shortcut creation with proper AppUserModelID to enable "full toast branding when launching PowerShell."
|
||
|
||
## Important Notes
|
||
The web page content provided doesn't explicitly address interactive session requirements or detailed protocol activation information.
|
||
|
||
## [FETCH #10] https://healthchecks.io/docs/powershell/
|
||
**ASK:** Give the full PowerShell examples on the page (Invoke-RestMethod ping, /start, /fail, /{exit-status} endpoints, POST body, Task Scheduler command line, retries/timeout guidance), plus anything about the free plan limits.
|
||
|
||
# PowerShell Monitoring with Healthchecks.io
|
||
|
||
Based on the documentation provided, here's what's available:
|
||
|
||
## Basic Ping Example
|
||
The page shows a simple ping command:
|
||
```powershell
|
||
Invoke-RestMethod https://hc-ping.com/your-uuid-here
|
||
```
|
||
|
||
## POST Request with Diagnostic Data
|
||
You can send additional information via POST:
|
||
```powershell
|
||
Invoke-RestMethod -Uri https://hc-ping.com/your-uuid-here -Method Post -Body "temperature=-7"
|
||
```
|
||
|
||
## Task Scheduler Command Line
|
||
The documented execution method is:
|
||
```
|
||
powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
|
||
```
|
||
|
||
Alternatively, pass the command directly:
|
||
```
|
||
powershell.exe -Command "&{Invoke-RestMethod https://hc-ping.com/your-uuid-here}"
|
||
```
|
||
|
||
## Important Limitations
|
||
The page provided does **not** include information about:
|
||
- `/start`, `/fail`, or `/{exit-status}` endpoints
|
||
- Retry or timeout guidance
|
||
- Free plan limits
|
||
|
||
The documentation only demonstrates basic pinging functionality. For the additional endpoints and plan details you requested, you would need to consult the full Healthchecks.io API documentation or other guides listed in their navigation menu.
|
||
|
||
## [FETCH #11] https://learn.microsoft.com/en-us/windows/wsl/systemd
|
||
**ASK:** Summarize: how to enable systemd in WSL ([boot] systemd=true in /etc/wsl.conf), required WSL version, whether services like cron persist when no WSL session is open, and any statement about WSL starting automatically at boot or the need to start it from Windows.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Use systemd to manage Linux services with WSL | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/wsl/systemd
|
||
breadcrumb_path: /windows/wsl/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-Windows-DevTools
|
||
recommendations: true
|
||
feedback_product_url: https://github.com/microsoft/WSL/issues
|
||
feedback_system: OpenSource
|
||
ms.service: dev-environment
|
||
ms.subservice: windows-subsystem-for-linux
|
||
author: GrantMeStrength
|
||
ms.author: jken
|
||
ms.reviewer: crloewen
|
||
adobe-target: true
|
||
description: Learn how to use systemd to manage Linux services with Windows Subsystem for Linux.
|
||
ms.date: 2025-01-13T00:00:00.0000000Z
|
||
ms.topic: how-to
|
||
locale: en-us
|
||
document_id: 0cab5a55-dcd1-2133-25db-14113d6e9843
|
||
document_version_independent_id: 0cab5a55-dcd1-2133-25db-14113d6e9843
|
||
updated_at: 2026-06-02T16:58:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/WSL/blob/live/WSL/systemd.md
|
||
gitcommit: https://github.com/MicrosoftDocs/WSL/blob/7b28cc1ee9b8ff672ada5e1c6c326d3573d703e5/WSL/systemd.md
|
||
git_commit_id: 7b28cc1ee9b8ff672ada5e1c6c326d3573d703e5
|
||
site_name: Docs
|
||
depot_name: WS.wsl
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/WS.wsl/{branchName}{pdfName}
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 992
|
||
asset_id: systemd
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: WSL/systemd.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: a653d0ff-06c0-d792-c759-1dabb28e3955
|
||
---
|
||
|
||
# Use systemd to manage Linux services with WSL | Microsoft Learn
|
||
|
||
Windows Subsystem for Linux (WSL) now supports systemd, an init system and service manager used by many popular Linux distributions such as Ubuntu, Debian, and more. (What is systemd?).
|
||
|
||
|
||
|
||
The init system default has recently changed from SystemV, with [systemd now the default for the current version of Ubuntu](https://canonical.com/blog/ubuntu-desktop-23-04-release-roundup#:%7E:text=Systemd%20becomes%20the%20default%20for%20Ubuntu%20on%20WSL) that will be installed using the [`wsl --install` command](install) default. Linux distributions other than the current version of Ubuntu may still use the WSL init, similar to SystemV init. To change to systemd, see How to enable systemd.
|
||
|
||
|
||
|
||
## What is systemd in Linux?
|
||
|
||
|
||
|
||
According to https://systemd.io: "systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system."
|
||
|
||
|
||
|
||
Primarily an init system and service manager, systemd includes features like on-demand starting of daemons, mount and automount point maintenance, snapshot support, and processes tracking using Linux control groups.
|
||
|
||
|
||
|
||
Most major Linux distributions now run systemd, so enabling it on WSL brings the experience even closer to using bare-metal Linux. See the video announcement with systemd demos or examples of using systemd below to learn more about what systemd has to offer.
|
||
|
||
|
||
|
||
## How to enable systemd?
|
||
|
||
|
||
|
||
Systemd is [now the default for the current version of Ubuntu](https://canonical.com/blog/ubuntu-desktop-23-04-release-roundup#:%7E:text=Systemd%20becomes%20the%20default%20for%20Ubuntu%20on%20WSL) that will be installed using the [`wsl --install` command](install) default.
|
||
|
||
|
||
|
||
To enable systemd for any other Linux distributions running on WSL 2 (changing the default from using the systemv init):
|
||
|
||
|
||
|
||
1. Ensure that your WSL version is 0.67.6 or newer:
|
||
|
||
|
||
|
||
- to check, run `wsl --version`; if the command throws `Invalid command line option: --version` error, you must update WSL;
|
||
|
||
- to update, run `wsl --update` or [download the latest version from the Microsoft Store](https://aka.ms/wslstorepage).
|
||
|
||
2. Open a command line for your Linux distribution and enter `cd /` to access the root directory, then `ls` to list the files. You will see a directory named "etc" that contains the WSL configuration file for the distribution. Open this file so that you can make an update with the Nano text editor by entering: `nano /etc/wsl.conf`.
|
||
|
||
3. Add these lines in the `wsl.conf` file that you now have open to change the init used to systemd:
|
||
|
||
|
||
|
||
```bash
|
||
|
||
[boot]
|
||
|
||
systemd=true
|
||
|
||
```
|
||
|
||
|
||
|
||

|
||
|
||
4. Exit the Nano text editor (Ctrl + X, type Y to save your change and confirm with the `enter` key).
|
||
|
||
5. You will then need to close the Linux distribution. You can use the command `wsl.exe --shutdown` in PowerShell to restart all WSL instances.
|
||
|
||
6. Once you restart the Linux distribution, systemd will be running. You can verify it by using the command `systemctl status` to show the *running* state and the command `systemctl list-unit-files --type=service`, which will show the status of any services associated with your Linux distribution.
|
||
|
||
|
||
|
||
If your Linux distribution is Debian/Ubuntu/Kali Rolling, you should not only have installed the systemd package, but also make sure the systemd-sysv package is installed.
|
||
|
||
|
||
|
||
```bash
|
||
|
||
sudo apt-get update -y && sudo apt-get install systemd systemd-sysv -y
|
||
|
||
```
|
||
|
||
|
||
|
||
Learn more about [Advanced settings configuration in WSL](wsl-config), including the difference between the `wsl.conf` (distribution-specific) and `.wslconfig` (global) config files, how to update automount settings, etc.
|
||
|
||
|
||
|
||
## Systemd demo video
|
||
|
||
|
||
|
||
Microsoft partnered with Canonical to bring systemd support to WSL. See Craig Loewen (PM for WSL at Microsoft) and Oliver Smith (PM for Ubuntu on WSL at Canonical) announce systemd support and show some demos of what it enables.
|
||
|
||
|
||
|
||
- [Systemd support blog announcement](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/)
|
||
|
||
- [Oliver's tutorials based on these demos on the Ubuntu blog](https://ubuntu.com/blog/ubuntu-wsl-enable-systemd) - includes "Use snap to create a Nextcloud instance in minutes on WSL", "Manage your web projects with LXD", and ["Run a .Net Echo Bot as a systemd service on Ubuntu WSL"](https://ubuntu.com/tutorials/run-dotnet-echo-bot-with-systemd-on-ubuntu-wsl#1-overview)
|
||
|
||
- [Craig's microk8s demo on GitHub](https://github.com/craigloewen-msft/microk8sdemo)
|
||
|
||
|
||
|
||
## Systemd examples
|
||
|
||
|
||
|
||
A few examples of Linux applications that depend on systemd are:
|
||
|
||
|
||
|
||
- [snap](https://snapcraft.io/): a software packaging and deployment system developed by Canonical for operating systems that use the Linux kernel and the systemd init system. The packages are called "snaps", the command line tool for building snaps is called "Snapcraft", the central repository where snaps can be downloaded/installed is called the "Snap Store", and the daemon required to run snaps (download from the store, mount into place, confine, and run apps out of them) is called "snapd". The entire system is sometimes referred to as "snappy." Try running the command: `snap install spotify`.
|
||
|
||
- [microk8s](https://microk8s.io/): an open-source, low-ops, minimal production Kubernetes that automates deployment, scaling, and management of containerized apps. Follow the instructions to [Install MicroK8s on WSL2](https://microk8s.io/docs/install-wsl2), check out the [Get Started Tutorial](https://microk8s.io/docs/getting-started), or watch the video on [Kubernetes on Windows with MicroK8s and WSL 2](https://ubuntu.com/blog/kubernetes-on-windows-with-microk8s-and-wsl-2).
|
||
|
||
- [systemctl](https://www.linode.com/docs/guides/introduction-to-systemctl/): a command-line utility used to control and inspect systemd and to help you interact with services on your Linux distribution. Try the command: `systemctl list-units --type=service` to see which services are available and their status.
|
||
|
||
|
||
|
||
A few related tutorials demonstrating ways to use systemd:
|
||
|
||
|
||
|
||
- [Understanding and Using Systemd](https://www.linux.com/training-tutorials/understanding-and-using-systemd/)
|
||
|
||
- [Systemd Essentials: Working with the Services, Units, and the Journal](https://www.digitalocean.com/community/tutorials/systemd-essentials-working-with-services-units-and-the-journal)
|
||
|
||
- [How To Sandbox Processes With Systemd On Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-sandbox-processes-with-systemd-on-ubuntu-20-04)
|
||
|
||
|
||
|
||
## How does enabling systemd affect WSL architecture?
|
||
|
||
|
||
|
||
Enabling support for systemd required changes to the WSL architecture. As systemd requires PID 1, the WSL init process started within the Linux distribution becomes a child process of the systemd. Because the WSL init process is responsible for providing the infrastructure for communication between the Linux and Windows components, changing this hierarchy required rethinking some of the assumptions made with the WSL init process. Additional modifications had to be made to ensure a clean shutdown (as that shutdown is controlled by systemd now) and to have compatibility with [WSLg](tutorials/gui-apps), the component of WSL that runs Linux Graphical User Interfaces (GUIs), or the Linux apps that display in windows rather than the command line.
|
||
|
||
|
||
|
||
It is also important to note that with these changes, systemd services will NOT keep your WSL instance alive. Your WSL instance will stay alive in the same way it did previous to this update, which you can read more about in this [Background Task Support blog post from 2017](https://devblogs.microsoft.com/commandline/background-task-support-in-wsl/).
|
||
|
||
## [FETCH #12] https://github.com/winsw/winsw
|
||
**ASK:** Summarize WinSW: current release version and date, whether it is still maintained, XML config example (id, name, executable, arguments, onfailure action="restart" delay, resetfailure, log mode roll-by-size, startmode, env), install/start commands, and .NET requirements.
|
||
|
||
# WinSW Summary
|
||
|
||
**Current Release & Maintenance**
|
||
WinSW 3.x is in active development on the default `v3` branch. GitHub Releases contain stable 2.x versions and 3.x pre-releases, while NuGet and Maven packages currently support 2.x. The project remains maintained.
|
||
|
||
**XML Configuration Example**
|
||
The documentation provides this sample structure:
|
||
```xml
|
||
<service>
|
||
<id>jenkins</id>
|
||
<name>Jenkins</name>
|
||
<description>This service runs Jenkins continuous integration system.</description>
|
||
<env name="JENKINS_HOME" value="%BASE%"/>
|
||
<executable>java</executable>
|
||
<arguments>-Xrs -Xmx256m -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>
|
||
<log mode="roll"></log>
|
||
</service>
|
||
```
|
||
|
||
**Installation & Start Commands**
|
||
- Install: `winsw install myapp.xml [options]`
|
||
- Start: `winsw start myapp.xml`
|
||
|
||
**Runtime Requirements**
|
||
WinSW 3 requires ".NET Framework 4.6.1 or later" or native executables based on .NET 7. The framework has been "preinstalled since Windows 10, version 1511 and Windows Server 2016" and is installable on Windows 7 SP1 and Server 2008 R2 SP1 and later.
|
||
|
||
**License**
|
||
The project uses the MIT license, described as "permissive."
|
||
|
||
## [FETCH #13] https://learn.microsoft.com/en-us/answers/questions/1180993/scheduled-tasks-with-startup-trigger-not-firing
|
||
**ASK:** Summarize the question and the accepted/most useful answer: what causes 'At startup' triggers not to fire, the relation to Fast Startup / hybrid shutdown, and the suggested workarounds (event triggers, powercfg /h off, etc.).
|
||
|
||
# Summary: Scheduled Tasks with "Startup" Trigger Not Firing
|
||
|
||
## The Problem
|
||
|
||
A Windows Server 2012 user reported that scheduled tasks with "Startup" triggers stopped firing reliably in recent weeks. The issue affects:
|
||
- Custom tasks and built-in Windows tasks
|
||
- Either all tasks fire or none fire
|
||
- Event logs show tasks aren't being triggered at all
|
||
- The problem persists despite running SFC /SCANNOW
|
||
|
||
## Initial Response (Limited Usefulness)
|
||
|
||
The provided answer suggests:
|
||
1. A possible bug related to password verification when "When the computer starts" is selected
|
||
2. Using the startup folder as a workaround: `%allusersprofile%\Microsoft\Windows\Start Menu\Programs\Startup`
|
||
|
||
However, **the question author rejected this answer** because:
|
||
- The issue is not authentication-related
|
||
- This was a regression (tasks worked weeks prior)
|
||
- The problem is specific to Task Scheduler's "Startup" trigger mechanism
|
||
|
||
## Key Details Missing from Content
|
||
|
||
The webpage content provided does **not include** discussion of:
|
||
- Fast Startup / Hybrid Shutdown (a common culprit for startup trigger issues)
|
||
- Event trigger alternatives
|
||
- `powercfg /h off` solutions
|
||
- Other documented workarounds
|
||
|
||
## Suggested Workaround Mentioned
|
||
|
||
The user considered creating a PowerShell solution:
|
||
```powershell
|
||
Get-ScheduledTask | Where-Object {$_.Triggers.TriggerType -eq 'Startup'} | Start-ScheduledTask
|
||
```
|
||
This could be triggered via shortcut or `HKLM\...\Run` registry key.
|
||
|
||
**Note:** The provided content doesn't contain a complete or satisfactory resolution to this issue.
|
||
|
||
## [FETCH #14] https://docs.docker.com/engine/containers/start-containers-automatically/
|
||
**ASK:** Summarize the restart policies (no, on-failure[:max-retries], always, unless-stopped), their behavior on daemon restart / host reboot, and the note that Docker Desktop must itself be running (autostart at login) for containers to come up.
|
||
|
||
# Docker Restart Policies Summary
|
||
|
||
Docker offers four restart policies to control automatic container startup:
|
||
|
||
**Policy Overview:**
|
||
|
||
- **`no`** – "Don't automatically restart the container. (Default)"
|
||
- **`on-failure[:max-retries]`** – Restarts only on non-zero exit codes, with optional retry limits. Does not restart if the daemon restarts.
|
||
- **`always`** – "Always restart the container if it stops" except when manually stopped, then only restarts after daemon restart.
|
||
- **`unless-stopped`** – Similar to `always`, but containers remain stopped even after daemon restart if manually stopped.
|
||
|
||
**Daemon Restart Behavior:**
|
||
|
||
When the Docker daemon restarts, containers with `always` and `unless-stopped` policies will resume running. The `on-failure` policy does not trigger on daemon restart. The `no` policy never auto-restarts.
|
||
|
||
**Important Limitation:**
|
||
|
||
The provided documentation does not address Docker Desktop autostart at login or container startup requirements when the Docker daemon itself isn't running. To ensure containers automatically start after system reboot, you would need to separately configure Docker Desktop (or the Docker daemon) to launch automatically—a prerequisite the documentation doesn't explicitly detail for desktop environments.
|
||
|
||
## [FETCH #15] https://learn.microsoft.com/en-us/sysinternals/downloads/autologon
|
||
**ASK:** Summarize what Autologon does, how credentials are stored (LSA secret, encrypted), the command-line usage (autologon user domain password), how to disable it (Ctrl+Shift+Alt, or run again), and security warnings.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Autologon - Sysinternals | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/sysinternals/downloads/autologon
|
||
ms.subservice: system-utilities
|
||
ms.service: sysinternals
|
||
uhfHeaderId: MSDocsHeader-Sysinternals
|
||
breadcrumb_path: /sysinternals/bread/toc.json
|
||
author: markruss
|
||
ms.author: markruss
|
||
ms.topic: system-utilities
|
||
TOCTitle: Autologon
|
||
description: Bypass password screen during logon.
|
||
ms:assetid: 121f300c-85cb-418d-8199-48e587d864c3
|
||
ms:mtpsurl: https://technet.microsoft.com/Bb963905(v=MSDN.10)
|
||
ms.date: 2020-09-17T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: fe79fa33-14da-3d3a-064f-355f1c2ccfbd
|
||
document_version_independent_id: ac9aca2d-dd75-8002-a19d-e2e0a7ef0335
|
||
updated_at: 2021-07-27T18:14:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/sysinternals/blob/live/sysinternals/downloads/autologon.md
|
||
gitcommit: https://github.com/MicrosoftDocs/sysinternals/blob/46cfcae426f1289a9b857420f32353d0a6a7f52f/sysinternals/downloads/autologon.md
|
||
git_commit_id: 46cfcae426f1289a9b857420f32353d0a6a7f52f
|
||
site_name: Docs
|
||
depot_name: MSDN.sysinternals
|
||
page_type: conceptual
|
||
toc_rel: ../toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.sysinternals/{branchName}{pdfName}
|
||
feedback_system: None
|
||
feedback_product_url: ''
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 226
|
||
asset_id: downloads/autologon
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: sysinternals/downloads/autologon.md
|
||
cmProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/4ca1c773-9341-4241-b9f7-b89d0b8ec794
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/dd6bfba4-3d64-4c95-ab74-30bcb91cb6a3
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 2083d565-fa0f-1615-7832-a230674167bb
|
||
---
|
||
|
||
# Autologon - Sysinternals | Microsoft Learn
|
||
|
||
**By Mark Russinovich**
|
||
|
||
|
||
|
||
Published: August 29, 2016
|
||
|
||
|
||
|
||
[](https://download.sysinternals.com/files/AutoLogon.zip)[**Download Autologon**](https://download.sysinternals.com/files/AutoLogon.zip)**(495 KB)** **Run now** from [Sysinternals Live](https://live.sysinternals.com/Autologon.exe).
|
||
|
||
|
||
|
||
## Introduction
|
||
|
||
|
||
|
||
Autologon enables you to easily configure Windows’ built-in autologon mechanism. Instead of waiting for a user to enter their name and password, Windows uses the credentials you enter with Autologon, which are encrypted in the Registry, to log on the specified user automatically.
|
||
|
||
|
||
|
||
[!WARNING] Although the password is encrypted in the registry as an *LSA secret*, a user with administrative rights can easily retrieve and decrypt it. (For more information see [Protecting the Automatic Logon Password](/en-us/windows/win32/secauthn/protecting-the-automatic-logon-password/) )
|
||
|
||
|
||
|
||
*Autologon* is easy enough to use. Just run autologon.exe, fill in the dialog, and hit Enable. The next time the system starts, Windows will try to use the entered credentials to log on the user at the console. Note that Autologon does not verify the submitted credentials, nor does it verify that the specified user account is allowed to log on to the computer.
|
||
|
||
|
||
|
||
To turn off auto-logon, hit *Disable*. Also, if the shift key is held down before the system performs an autologon, the autologon will be disabled for that logon. You can also pass the username, domain and password as command-line arguments:
|
||
|
||
|
||
|
||
**autologon user domain password**
|
||
|
||
|
||
|
||
**Note:** When Exchange Activesync password restrictions are in place, Windows will not process the autologon configuration.
|
||
|
||
|
||
|
||
[](https://download.sysinternals.com/files/AutoLogon.zip)[**Download Autologon**](https://download.sysinternals.com/files/AutoLogon.zip)**(495 KB)** **Run now** from [Sysinternals Live](https://live.sysinternals.com/Autologon.exe).
|
||
|
||
## [FETCH #16] https://github.com/GitHub30/win11toast
|
||
**ASK:** Summarize: install command, minimal example (toast('title','body')), buttons with protocol/URL launch, on_click callback, app_id, image, progress, dialog, and any note about the notification not showing when running as a service / from Task Scheduler non-interactively. Also requirement on winsdk/winrt package.
|
||
|
||
# win11toast Summary
|
||
|
||
**Installation:**
|
||
```
|
||
pip install win11toast
|
||
```
|
||
|
||
**Minimal Example:**
|
||
```python
|
||
from win11toast import toast
|
||
toast('Hello Python🐍')
|
||
```
|
||
|
||
**Basic Usage with Title & Body:**
|
||
```python
|
||
toast('Hello Python', 'Click to open url', on_click='https://www.python.org')
|
||
```
|
||
|
||
**Buttons with Protocol/URL:**
|
||
```python
|
||
buttons = [
|
||
{'activationType': 'protocol', 'arguments': 'https://google.com', 'content': 'Open Google'},
|
||
{'activationType': 'protocol', 'arguments': 'file:///C:/Windows/Media', 'content': 'Open Folder'}
|
||
]
|
||
toast('Title', 'Body', buttons=buttons)
|
||
```
|
||
|
||
**On-Click Callback:**
|
||
```python
|
||
toast('Hello', 'Message', on_click=lambda args: print('clicked!', args))
|
||
```
|
||
|
||
**Images:**
|
||
```python
|
||
toast('Hello', 'Body', image='https://example.com/image.png')
|
||
# Or with placement
|
||
toast('Hello', 'Body', image={'src': 'url', 'placement': 'hero'})
|
||
```
|
||
|
||
**Progress Bar:**
|
||
```python
|
||
from win11toast import notify, update_progress
|
||
notify(progress={'title': 'Title', 'status': 'Downloading...', 'value': '0'})
|
||
update_progress({'value': 0.5, 'valueStringOverride': '50%'})
|
||
```
|
||
|
||
**Text-to-Speech:**
|
||
```python
|
||
toast('Hello Python🐍', dialogue='Hello world')
|
||
```
|
||
|
||
**Important Note:** The documentation does not mention requiring a specific `app_id` parameter or discuss limitations when running as a service/from Task Scheduler. Dependencies include WinRT libraries for Windows 10/11 integration.
|
||
|
||
## [FETCH #17] https://learn.microsoft.com/en-us/answers/questions/593292/how-to-write-windows-event-logs-in-powershell-7
|
||
**ASK:** Summarize the answers: what replaces Write-EventLog in PowerShell 7 (New-WinEvent limitations, System.Diagnostics.EventLog .NET class usage, calling powershell.exe 5.1), and any working code sample.
|
||
|
||
# Write-EventLog Replacement in PowerShell 7+
|
||
|
||
## The Challenge
|
||
The `Write-EventLog` cmdlet is deprecated in PowerShell 7+ because it relies on unsupported APIs. Finding a direct replacement is non-trivial.
|
||
|
||
## Available Options
|
||
|
||
### 1. **New-WinEvent (Limited)**
|
||
The `New-WinEvent` cmdlet exists but has significant limitations:
|
||
- It creates **Event Tracing for Windows (ETW) events**, not traditional Windows Event Log entries
|
||
- It's designed for ETW channels, not the classic Application/System/Security logs
|
||
- **Not a true replacement** for `Write-EventLog`
|
||
|
||
### 2. **System.Diagnostics.EventLog .NET Class**
|
||
A workaround for PowerShell 7 is to use the underlying .NET `System.Diagnostics.EventLog` class:
|
||
|
||
```powershell
|
||
[System.Diagnostics.EventLog]::WriteEntry("MySource", "Message text", [System.Diagnostics.EventLogEntryType]::Information, 1000)
|
||
```
|
||
|
||
This approach:
|
||
- Works in both PowerShell 5 and 7
|
||
- Provides direct .NET access to event logging functionality
|
||
- Requires the event source to be pre-registered on the system
|
||
|
||
### 3. **System.Diagnostics.TraceSource with EventLogTraceListener**
|
||
Alternative approach using diagnostic tracing configured in an app.config file (more complex but flexible):
|
||
- Requires System.Diagnostics configuration
|
||
- Better for complex logging scenarios with multiple listeners
|
||
|
||
## Practical Recommendation
|
||
**For most scenarios**: Use the .NET `System.Diagnostics.EventLog` class directly, as it most closely replicates `Write-EventLog` functionality. If you need Windows-only logging and don't have a strong requirement for PowerShell 7, PowerShell 5.1 remains the better choice.
|
||
|
||
## [FETCH #18] https://nssm.cc/usage
|
||
**ASK:** Summarize NSSM usage: nssm install, nssm set <svc> AppExit Default Restart, AppRestartDelay, AppThrottle, AppStdout/AppStderr logging, AppRotateFiles, AppStopMethodSkip, and any notes about running in Session 0 / interactive desktop, and the current version and its age.
|
||
|
||
# NSSM Usage Summary
|
||
|
||
**Installation & Basic Commands:**
|
||
- `nssm install <servicename>` launches a GUI installer with multiple configuration tabs
|
||
- `nssm install <servicename> <application> [options]` enables command-line installation
|
||
- `nssm remove <servicename>` removes services with confirmation
|
||
|
||
**Key Registry Parameters:**
|
||
|
||
**Restart Behavior:**
|
||
- `AppExit`: Set to "Restart," "Ignore," or "Exit" (defaults to restart if not configured)
|
||
- `AppRestartDelay`: Milliseconds to wait between restarts; service shows as "Paused" during delay
|
||
- `AppThrottle`: Prevents CPU loops by throttling if app exits before threshold (default 1500ms); doubles wait time up to 256 seconds maximum
|
||
|
||
**Logging & File Rotation:**
|
||
- `AppStdout`/`AppStderr`: Redirect application output to specified file paths
|
||
- `AppRotateFiles`: Enable rotation; existing files renamed with ISO8601 timestamps
|
||
- `AppRotateOnline`: Rotate files while running based on size limits
|
||
- `AppRotateSeconds`/`AppRotateBytes`: Set rotation thresholds
|
||
|
||
**Shutdown Control:**
|
||
- `AppStopMethodSkip`: Sum values (1=skip Control-C, 2=skip WM_CLOSE, 4=skip WM_QUIT, 8=skip TerminateProcess) to disable shutdown methods
|
||
- Default timeouts: 1500ms per method; configurable via `AppStopMethodConsole`, `AppStopMethodWindow`, `AppStopMethodThreads`
|
||
|
||
**Desktop/Session Limitations:**
|
||
The documentation contains no explicit information regarding Session 0 isolation or interactive desktop restrictions.
|
||
|
||
**Version Information:**
|
||
Not provided in the source material.
|
||
|
||
## [SEARCH #17] Task Scheduler BootTrigger Delay element XML PT1M "Delay task for" startup trigger site:learn.microsoft.com
|
||
|
||
Web search results for query: "Task Scheduler BootTrigger Delay element XML PT1M "Delay task for" startup trigger site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"BootTrigger.Delay property - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/boottrigger-delay"},{"title":"IRegistrationTrigger::get_Delay (taskschd.h) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-iregistrationtrigger-get_delay"},{"title":"[MS-TSCH]: BootTrigger | Microsoft Learn","url":"https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/dfcb1665-2a76-4fa7-b4d4-fdb5387d5d7c"},{"title":"Delay (registrationTriggerType) Element - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-delay-registrationtriggertype-element"},{"title":"BootTrigger object - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/boottrigger"},{"title":"BootTrigger (triggerGroup) Element - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-boottrigger-triggergroup-element"},{"title":"boottrigger delay","url":"https://learn.microsoft.com/el-gr/windows/win32/taskschd/boottrigger-delay"},{"title":"Delay (bootTriggerType) Element","url":"https://learn.microsoft.com/en-gb/windows/win32/taskschd/taskschedulerschema-delay-boottriggertype-element"},{"title":"Delay (bootTriggerType) Element","url":"https://learn.microsoft.com/en-us/windows/win32/TaskSchd/taskschedulerschema-delay-boottriggertype-element"},{"title":"BootTrigger (triggerGroup) Element","url":"https://learn.microsoft.com/en-gb/windows/win32/taskschd/taskschedulerschema-boottrigger-triggergroup-element"}]
|
||
|
||
I've found comprehensive information about the Task Scheduler BootTrigger Delay element from Microsoft Learn. Here are the key details:
|
||
|
||
## BootTrigger Delay Element
|
||
|
||
The Delay element specifies the amount of time between when the system is booted and when the task is started.
|
||
|
||
### XML Format and Schema
|
||
|
||
The Delay element is defined by the bootTriggerType complex type. The element uses the xs:duration type with a default value of "PT0M" and is optional.
|
||
|
||
### Duration Format
|
||
|
||
The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes).
|
||
|
||
### Example XML
|
||
|
||
A boot trigger with a 5-minute delay would use: `<Delay>PT5M</Delay>`
|
||
|
||
### Script and Development
|
||
|
||
For script development, the boot trigger delay is specified by the BootTrigger.Delay property, and for C++ development, it's specified by the IBootTrigger::Delay property.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #18] Windows 11 Focus assist do not disturb priority notifications toast suppressed app added to priority list PowerShell
|
||
|
||
Web search results for query: "Windows 11 Focus assist do not disturb priority notifications toast suppressed app added to priority list PowerShell"
|
||
|
||
Links: [{"title":"How to Set Priority Notifications for Do Not Disturb in Windows 11 | NinjaOne","url":"https://www.ninjaone.com/blog/priority-notifications-for-do-not-disturb/"},{"title":"Turn On or Off Focus Assist in Windows 11 | Windows 11 Forum","url":"https://www.elevenforum.com/t/turn-on-or-off-focus-assist-in-windows-11.1351/"},{"title":"How to use Focus assist to avoid distractions in Windows 11 | Windows Central","url":"https://www.windowscentral.com/how-use-focus-assist-avoid-distractions-windows-11"},{"title":"How to Use Focus Assist on Windows 11","url":"https://nerdschalk.com/how-to-use-focus-assist-on-windows-11/"},{"title":"How to Use Focus Assist on Windows 11","url":"https://www.groovypost.com/howto/use-focus-assist-on-windows-11/"},{"title":"Windows Notifications: Silence Noise with Do Not Disturb & Focus","url":"https://windowsforum.com/threads/master-windows-notifications-silence-noise-with-do-not-disturb-and-focus-assist.404264/"},{"title":"Windows 11 Focus Assist Explained","url":"https://onewebcare.com/windows/windows-11-focus-assist/"},{"title":"How to reduce distractions in Windows 11 with Focus Assist","url":"https://www.techradar.com/how-to/how-to-reduce-distractions-in-windows-11"}]
|
||
|
||
Based on the search results, here's information about Windows 11 Focus Assist, Do Not Disturb, priority notifications, toast suppression, and PowerShell configuration:
|
||
|
||
## Overview
|
||
|
||
Starting with Windows 11 build 22557, Microsoft reimagined focus assist experiences and it is now called Do not disturb. You can set priority notifications to control whether calls, reminders, and specific apps break through when do not disturb is on.
|
||
|
||
## Priority Notifications
|
||
|
||
When Focus turns on Do Not Disturb, only apps in the priority list can send notifications. Suppressed notifications produce no sound, vibration, or visual pop-up when they arrive. The notification silently queues in the Action Center with its original timestamp preserved.
|
||
|
||
## PowerShell Configuration
|
||
|
||
If you manage multiple devices, you can script notification settings by modifying the Windows registry. This still applies per-user, so you'll need to run any scripts that modify priority notification behavior at logon. The PowerShell commands you'll need to enable or disable do not disturb modify the HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings registry path.
|
||
|
||
You can programmatically configure other notification settings by modifying the HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\<App ID> keys – each application will have its own unique AppID and settings in this location.
|
||
|
||
## Adding Apps to Priority List
|
||
|
||
If you want to add an app, click the Add an app button and select the app you wish to receive notifications from when Focus Assist is enabled.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #19] Windows Update active hours set registry ActiveHoursStart ActiveHoursEnd avoid restart schedule Windows 11 PowerShell
|
||
|
||
Web search results for query: "Windows Update active hours set registry ActiveHoursStart ActiveHoursEnd avoid restart schedule Windows 11 PowerShell"
|
||
|
||
Links: [{"title":"Set Active Hours for Windows Update in Windows 11 | Windows 11 Forum","url":"https://www.elevenforum.com/t/set-active-hours-for-windows-update-in-windows-11.3436/"},{"title":"Script to update active hours on Windows 10/11 devices - Hexnode Help Center","url":"https://www.hexnode.com/mobile-device-management/help/script-to-update-active-hours-on-windows-10-11-devices/"},{"title":"Set Active Hours To Avoid Random Restarts In Windows 11 HTMD Blog","url":"https://www.anoopcnair.com/set-active-hours-to-avoid-restarts-windows-11/"},{"title":"3 Ways to Change Windows 10 Active Hours - MajorGeeks","url":"https://www.majorgeeks.com/content/page/3_ways_to_change_windows_10_active_hours.html"},{"title":"How to configure and use Active Hours in Windows 11","url":"https://www.thewindowsclub.com/configure-and-use-active-hours-in-windows-10"},{"title":"How to Disable Active Hours in Windows 11: The Ultimate Power User Guide","url":"https://techradar.info/how-to-disable-active-hours-in-windows-11-the-ultimate-power-user-guide/"},{"title":"update active hours","url":"https://github.com/Maimer/update-active-hours"},{"title":"A downloadable tool for Windows","url":"https://blearychicken.itch.io/no-reboot"},{"title":"MiWorkspace: Changing Active Hours on Windows 11 Computers","url":"https://teamdynamix.umich.edu/TDClient/30/Portal/KB/PrintArticle?ID=13604"}]
|
||
|
||
Based on the search results, here's comprehensive information about setting Windows Update active hours via registry with PowerShell for Windows 11:
|
||
|
||
## Registry Path and Values
|
||
|
||
The registry path is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings. The two key values you need to modify are:
|
||
|
||
- **ActiveHoursStart**: Uses 24-hour clock format for your active hours start time
|
||
- **ActiveHoursEnd**: Uses 24-hour clock format for your active hours end time
|
||
|
||
## Time Format
|
||
|
||
Time values can range from integer values 0-24 (0-12 meaning 12:00 A.M. to 12:00 P.M. and 13-24 meaning 1:00 P.M. to 12:00 A.M.). For example, 8 = 8:00 AM.
|
||
|
||
## PowerShell Method
|
||
|
||
The PowerShell script uses Set-ItemProperty cmdlet to configure the start and end of active hours. An example script to set active hours between 5:00 A.M. and 4:00 P.M. uses: reg add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "ActiveHoursStart" /t REG_DWORD /d 5 /f and reg add "HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" /v "ActiveHoursEnd" /t REG_DWORD /d 16 /f
|
||
|
||
## How It Works
|
||
|
||
A PowerShell script can update the registry values for the Active Hours start and end times so that the current time is always in Active Hours, which prevents the system from initiating a forced reboot.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #20] Task Scheduler daylight saving time trigger "Synchronize across time zones" calendar trigger behavior DST
|
||
|
||
Web search results for query: "Task Scheduler daylight saving time trigger "Synchronize across time zones" calendar trigger behavior DST"
|
||
|
||
Links: [{"title":"xScheduledTask: Trigger has no option for Synchronize across time zones · Issue #109 · dsccommunity/ComputerManagementDsc","url":"https://github.com/dsccommunity/ComputerManagementDsc/issues/109"},{"title":"Scheduled task timezone support | Changelog","url":"https://trigger.dev/changelog/scheduled-task-timezones"},{"title":"Scheduled Task Trigger - Synchronize Across Time Zones · The CLI Guy","url":"https://www.thecliguy.co.uk/2020/02/09/scheduled-task-trigger-synchronize-across-time-zones/"},{"title":"Windows Task Scheduler \"Synchronize accross time zones\" does not work as expected - can anyone explain?","url":"https://learn.microsoft.com/en-us/answers/questions/790592/windows-task-scheduler-synchronize-accross-time-zo"},{"title":"Task Scheduler run unexpectedly after server reboot following DST change","url":"https://learn.microsoft.com/en-us/answers/a/1978310"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/th-th/windows/win32/taskschd/monthlydowtrigger"},{"title":"windows scheduler - tasks are running at the same time despite different time settings","url":"https://learn.microsoft.com/en-us/answers/questions/1032006/windows-scheduler-tasks-are-running-at-the-same-ti"},{"title":"MonthlyDOWTrigger object","url":"https://learn.microsoft.com/en-us/windows/win32/TaskSchd/monthlydowtrigger"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-au/windows/win32/taskschd/weeklytrigger"},{"title":"MonthlyTrigger object","url":"https://learn.microsoft.com/sv-se/windows/win32/taskschd/monthlytrigger"}]
|
||
|
||
Based on the search results, here's information about Windows Task Scheduler's "Synchronize across time zones" setting and its behavior with daylight saving time:
|
||
|
||
## What "Synchronize Across Time Zones" Does
|
||
|
||
When you check the "Synchronize across time zones" option, the task is scheduled by UTC. If the computer's time zone is changed, the task will continue to run according to the UTC time recorded in the task's XML file.
|
||
|
||
## Default Behavior
|
||
|
||
When creating a scheduled task trigger using the Task Scheduler UI, the setting "Synchronize Across Time Zones" is disabled by default. However, the PowerShell cmdlet New-ScheduledTaskTrigger exhibits the opposite behavior.
|
||
|
||
## DST Behavior with Calendar Triggers
|
||
|
||
For weekly and monthly calendar triggers specifically, on the day that daylight savings time starts in a year, for a Pacific time zone (time shifted from 02:00 AM to 03:00 AM in 2022), any task that's scheduled to run between 02:00 AM and 02:59:59:999 AM will run at the earliest possible time that exists in that given day—that is, at 03:00 AM. This applies to all DST time zones based on the various times at which they observe DST.
|
||
|
||
## Known Issues
|
||
|
||
Users have reported issues with DST transitions. After the end of DST, jobs may run one hour early, but after removing "Synchronize across time zones" from the schedule, the start time becomes the current local non-DST time. Additionally, there appears to be a bug when using the "once per week on a specific day" option with DST changes.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #21] schtasks /Create /XML /RU /RP /RL HIGHEST example task XML import site:learn.microsoft.com
|
||
|
||
Web search results for query: "schtasks /Create /XML /RU /RP /RL HIGHEST example task XML import site:learn.microsoft.com"
|
||
|
||
Links: [{"title":"Schtasks.exe - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/schtasks"},{"title":"schtasks create | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create"},{"title":"Windows 10 - Task Scheduler - \"Author\" field in XML - Microsoft Q&A","url":"https://learn.microsoft.com/en-us/answers/questions/370031/windows-10-task-scheduler-author-field-in-xml"},{"title":"Importing XML into Task Scheduler | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/msdn-technet-forums/cdc10106-11b4-4ed4-b637-b33f0c1ce01c"},{"title":"Import Scheduled Task with Powershell | Microsoft Learn","url":"https://learn.microsoft.com/en-us/archive/msdn-technet-forums/34517e40-a827-41b2-b361-254894d80404"},{"title":"Weekly Trigger Example (XML) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/weekly-trigger-example--xml-"},{"title":"Time Trigger Example (XML) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/time-trigger-example--xml-"},{"title":"Logon Trigger Example (XML) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/logon-trigger-example--xml-"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/ja-jp/previous-versions/windows/it-pro/windows-xp/bb490996(v=technet.10)"}]
|
||
|
||
Here are the search results for `schtasks /Create /XML /RU /RP /RL HIGHEST example task XML import` from Microsoft Learn:
|
||
|
||
**Key Information:**
|
||
|
||
1. **XML Import with User Context:** The /XML parameter creates a task from an XML file and can be combined with /RU and /RP switches, or with the /RP switch alone when the task XML already contains the principal.
|
||
|
||
2. **Run Level Setting:** The /RL parameter sets the run level for the task, with valid values being LIMITED and HIGHEST.
|
||
|
||
3. **Basic Command Syntax:** Using Schtasks.exe tool, you can register a task with the command: `schtasks /create /XML <path to the XML file containing the task definition> /tn <task name>`
|
||
|
||
4. **Practical Example:** A working example format is: `schtasks.exe /create /RU domain\user /RP password /TN taskname /XML d:\test.xml`
|
||
|
||
5. **XML Encoding Note:** Even though Task Scheduler exports files as UTF-16, it refuses to read them unless they're UTF-8 encoded.
|
||
|
||
The search results provide comprehensive documentation on using `schtasks` with XML file imports, including parameter combinations and practical examples from Microsoft's official documentation.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #22] Task Scheduler last run result codes 0x41301 0x41306 0x1 0x800710E0 meaning
|
||
|
||
Web search results for query: "Task Scheduler last run result codes 0x41301 0x41306 0x1 0x800710E0 meaning"
|
||
|
||
Links: [{"title":"[BUG] win_task KeyError exception for LastTaskResult · Issue #66441 · saltstack/salt","url":"https://github.com/saltstack/salt/issues/66441"},{"title":"Task Scheduler error and success constants (WinError.h) - Win32 apps | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-error-and-success-constants"},{"title":"All Task Scheduler Errors and Success Codes | TechDirectArchive","url":"https://techdirectarchive.com/2020/03/24/task-scheduler-errors-and-success-code-what-does-code-0x41301-mean/"},{"title":"Task Scheduler Error and Success Codes explained","url":"https://www.thewindowsclub.com/task-scheduler-error-and-success-code-explained"},{"title":"Scheduled Tasks - Result Codes - Lakshmikanth Balasundaram","url":"https://www.lakshmikanth.com/scheduled-tasks-result-codes/"},{"title":"How to analyze Task Scheduler 0x41301 error code and fix it.","url":"https://www.get-itsolutions.com/task-scheduler-0x41301-error-code-fix/"},{"title":"Windows Scheduled tasks result codes - Starbeam Systems","url":"https://starbeamsystems.com/knowledge-base/16-windows/82-windows-scheduled-tasks-result-codes"},{"title":"Task Scheduler did not start monthly task after daylight saving change","url":"https://learn.microsoft.com/en-us/answers/questions/340419/task-scheduler-did-not-start-monthly-task-after-da?page=2"},{"title":"Task Scheduler did not start monthly task after daylight saving change","url":"https://learn.microsoft.com/en-us/answers/a/341974"},{"title":"community.qlik.com","url":"https://community.qlik.com/t5/Talend-Studio/Windows-Task-Scheduler-Last-Run-Result-0x2/td-p/2331821"}]
|
||
|
||
Based on the search results, here are the meanings of the Task Scheduler last run result codes you inquired about:
|
||
|
||
- **0x41301**: Task is currently running
|
||
- **0x41306**: Task is terminated
|
||
- **0x1**: Incorrect function called or unknown function called
|
||
- **0x800710E0**: "The operator or administrator has refused the request"
|
||
|
||
These codes are part of Windows Task Scheduler's standard error and success code system used to indicate the status and result of scheduled task executions.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #23] Task Scheduler "On an event" trigger custom XPath query Microsoft-Windows-TaskScheduler/Operational EventID 103 OR 203 alert on task failure
|
||
|
||
Web search results for query: "Task Scheduler "On an event" trigger custom XPath query Microsoft-Windows-TaskScheduler/Operational EventID 103 OR 203 alert on task failure"
|
||
|
||
Links: [{"title":"running a scheduled task after another","url":"https://learn.microsoft.com/en-us/archive/blogs/davethompson/running-a-scheduled-task-after-another"},{"title":"2.5.3.6 EventTrigger","url":"https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/34e05890-8338-408e-a87d-81534898126a"},{"title":"task scheduler task not running on triggerd time","url":"https://learn.microsoft.com/answers/questions/333001/task-scheduler-task-not-running-on-triggerd-time.html?orderby=oldest"},{"title":"EventTrigger object","url":"https://learn.microsoft.com/cs-cz/windows/desktop/TaskSchd/eventtrigger"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/en-us/windows/win32/taskschd/eventtrigger"},{"title":"IEventTrigger interface (taskschd.h)","url":"https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nn-taskschd-ieventtrigger"},{"title":"eventTriggerType Complex Type","url":"https://learn.microsoft.com/en-us/windows/win32/TaskSchd/taskschedulerschema-eventtriggertype-complextype"},{"title":"taskschedulerschema eventtrigger triggergroup element","url":"https://learn.microsoft.com/en-au/windows/win32/taskschd/taskschedulerschema-eventtrigger-triggergroup-element"},{"title":"Reference The Event That Triggered Your Task","url":"https://learn.microsoft.com/it-it/archive/blogs/otto/reference-the-event-that-triggered-your-task"},{"title":"github.com","url":"https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/TaskSchd/eventtrigger.md"}]
|
||
|
||
Based on the search results, here's information about using Task Scheduler "On an event" triggers with custom XPath queries:
|
||
|
||
## Event Trigger Overview
|
||
|
||
Event triggers start a task when a system event occurs. The Subscription property gets or sets the XPath query string that identifies the event that fires the trigger.
|
||
|
||
## Custom XPath Query Structure
|
||
|
||
The standard "On an event" trigger only allows you to specify the Event ID, but using a custom event filter allows far more control by populating a custom XML XPath. The XPath query string identifies the event that fires the trigger.
|
||
|
||
## XPath Query Example
|
||
|
||
An example XPath query can target specific event data, such as filtering by EventID and TaskName to identify which task triggered the event. The search results show an example with EventID 102 for task completion events.
|
||
|
||
## ValueQueries
|
||
|
||
ValueQueries gets or sets a collection of named XPath queries, with each query applied to the last matching event XML returned from the subscription query specified in the Subscription property.
|
||
|
||
For your specific use case with EventID 103 or 203 in Microsoft-Windows-TaskScheduler/Operational, you would structure an XPath query that filters by those event IDs to alert on task failure. The exact XPath syntax would need to reference the Event XML structure in the Microsoft-Windows-TaskScheduler/Operational event log channel.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #24] pywin32 win32serviceutil ServiceFramework example Python Windows service SvcDoRun SvcStop
|
||
|
||
Web search results for query: "pywin32 win32serviceutil ServiceFramework example Python Windows service SvcDoRun SvcStop"
|
||
|
||
Links: [{"title":"pywin32/win32/Lib/win32serviceutil.py at main · mhammond/pywin32","url":"https://github.com/mhammond/pywin32/blob/main/win32/Lib/win32serviceutil.py"},{"title":"Python as a Windows Service Example","url":"https://www.mssqltips.com/sqlservertip/7318/python-as-a-windows-service/"},{"title":"Pywin32/lib/x32/win32/lib/win32serviceutil.py at master · SublimeText/Pywin32","url":"https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32/lib/win32serviceutil.py"},{"title":"An example Windows service implemented with pywin32 wrappers. #python #windows-service #pywin32 · GitHub","url":"https://gist.github.com/drmalex07/10554232"},{"title":"Creating a one-file Windows service in Python with pywin32 and PyInstaller · Metallapan AB","url":"https://metallapan.se/post/windows-service-pywin32-pyinstaller/"},{"title":"Developing a python based Windows Service – Nathan Sanders","url":"https://www.nathanasanders.com/2022/04/09/developing-a-python-based-windows-service/"},{"title":"DEV Community","url":"https://dev.to/demola12/building-a-robust-windows-service-in-python-with-win32serviceutil-part-13-1k6k"},{"title":"www.oreilly.com","url":"https://www.oreilly.com/library/view/python-programming-on/1565926218/ch18s05s04.html"}]
|
||
|
||
Great! I found several resources about pywin32 and creating Windows services in Python. Here's what I found:
|
||
|
||
## ServiceFramework Overview
|
||
|
||
The ServiceFramework class has required attributes `_svc_name_` (the service name) and `_svc_display_name_` (the service display name), along with optional attributes like `_svc_deps_` (service dependencies) and `_svc_description_`.
|
||
|
||
## SvcDoRun and SvcStop Methods
|
||
|
||
For a minimal implementation of ServiceFramework, you need to handle `SvcDoRun` and `SvcStop` methods - `SvcDoRun` starts the service and doesn't return until stopped, while `SvcStop` stops the service.
|
||
|
||
## Example Implementation
|
||
|
||
A typical example includes a service class that implements `SvcStop()` to stop the service and report status, and `SvcDoRun()` to start the service, report running status, and run the service logic.
|
||
|
||
## Service Initialization
|
||
|
||
The main entry point checks the number of command line arguments - if no arguments are provided, it initializes and starts the service via `servicemanager.Initialize()`, `servicemanager.PrepareToHostSingle()`, and `servicemanager.StartServiceCtrlDispatcher()`, otherwise it handles command-line arguments like install/start/stop.
|
||
|
||
The search results contain practical code examples and detailed explanations from multiple sources including the official pywin32 repository, technical blogs, and documentation resources.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #25] powercfg /change standby-timeout-ac 0 hibernate-timeout-ac 0 /hibernate off Windows 11 keep PC awake scheduled task
|
||
|
||
Web search results for query: "powercfg /change standby-timeout-ac 0 hibernate-timeout-ac 0 /hibernate off Windows 11 keep PC awake scheduled task"
|
||
|
||
Links: [{"title":"PowerCfg command - Windows CMD","url":"https://ss64.com/nt/powercfg.html"},{"title":"PowerCFG Commands for Windows 11 and 10: Complete Guide","url":"https://www.itechguides.com/mastering-the-powercfg-command-on-windows-11-and-10/"},{"title":"How to Manage Windows 11 Power and Sleep Settings","url":"https://www.cloudspress.com/how-to-manage-your-windows-11-power-and-sleep-settings-a-step-by-step-guide/"},{"title":"PowerCFG Command Guide for Windows 11 and 10","url":"https://www.cloudspress.com/mastering-the-powercfg-command-on-windows-11-and-10/"},{"title":"PowerCFG Tutorial: A Complete Guide to Power Settings in Windows","url":"https://www.pchardwarepro.com/en/PowerCFG-tutorial:-A-complete-guide-to-mastering-power-management-in-Windows/"},{"title":"DEV Community","url":"https://dev.to/teoman_egeselcuk_d962da6/title-powershell-on-windows-11-home-how-to-cap-displaysleephibernate-at-5-minutes-300-s-7ag"},{"title":"Hibernate Enabled but Timed Hibernate Not Working","url":"https://learn.microsoft.com/en-us/answers/questions/3853365/hibernate-enabled-but-timed-hibernate-not-working"},{"title":"learn.microsoft.com","url":"https://learn.microsoft.com/nb-no/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh875530(v=ws.11)"}]
|
||
|
||
Based on the search results, here's what I found about your query:
|
||
|
||
## PowerCfg Command Syntax and Usage
|
||
|
||
The `/change` parameter allows you to modify settings in the current power scheme, including standby-timeout-ac, hibernate-timeout-ac and other timeout settings, with values specified in minutes.
|
||
|
||
## Command Breakdown
|
||
|
||
Your command components mean:
|
||
- **-ac** refers to AC power (plugged-in), while DC refers to battery power
|
||
- **standby-timeout-ac 0**: Sets standby timeout to 0 minutes when plugged in (prevents sleep)
|
||
- **hibernate-timeout-ac 0**: Sets hibernation timeout to 0 minutes when plugged in (prevents hibernation)
|
||
- **/hibernate off**: Disables hibernation functionality
|
||
|
||
## Keeping PC Awake with Scheduled Tasks
|
||
|
||
Wake timers can be enumerated with `/WakeTimers` and are typically used to run scheduled tasks. The `/waketimers` command helps locate which schedules are authorized to wake the computer from sleep or hibernation.
|
||
|
||
## Important Note
|
||
|
||
To make changes to power settings, Powercfg must be run from an elevated command prompt.
|
||
|
||
These commands work on Windows 11 to prevent sleep/hibernation and can be integrated with scheduled tasks to keep your PC awake as needed.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #26] BitLocker pre-boot PIN unattended reboot scheduled task autologon conflict "TPM only" headless server
|
||
|
||
Web search results for query: "BitLocker pre-boot PIN unattended reboot scheduled task autologon conflict "TPM only" headless server"
|
||
|
||
Links: [{"title":"How to Use BitLocker with PIN | Dell US","url":"https://www.dell.com/support/kbdoc/en-us/000142382/how-to-use-bitlocker-with-pin"},{"title":"How to Enable a Pre-Boot BitLocker PIN on Windows","url":"https://www.howtogeek.com/262720/how-to-enable-a-pre-boot-bitlocker-pin-on-windows/"},{"title":"BitLocker countermeasures | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows/security/operating-system-security/data-protection/bitlocker/countermeasures"},{"title":"Troubleshooting BitLocker policies from the client side - Intune | Microsoft Learn","url":"https://learn.microsoft.com/en-us/troubleshoot/mem/intune/device-protection/troubleshoot-bitlocker-policies"},{"title":"Notes on BitLocker and the TPM and the pre-boot password or PIN - The Old New Thing","url":"https://devblogs.microsoft.com/oldnewthing/20220412-00/?p=106468"},{"title":"How to enable Pre-Boot BitLocker startup PIN on Windows with Intune","url":"https://oliverkieselbach.com/2019/08/02/how-to-enable-pre-boot-bitlocker-startup-pin-on-windows-with-intune/comment-page-1/"},{"title":"Silently enable BitLocker with PIN during Autopilot | Katy's Tech Blog","url":"https://katystech.blog/mem/bitlocker-with-pin"},{"title":"Fix BitLocker Endless Recovery Key Prompt: Ultimate Troubleshooting Guide for Windows Users - 4idiotz","url":"https://4idiotz.com/tech/computers-and-operating-systems/bitlocker-troubleshooting/fix-bitlocker-endless-recovery-key-prompt-ultimate-troubleshooting-guide-for-windows-users/"}]
|
||
|
||
I found relevant search results for your query. Here are the key findings:
|
||
|
||
## Pre-boot PIN and Unattended Reboots
|
||
|
||
Preboot authentication can make it more difficult to update unattended or remotely administered devices because a PIN must be entered when a device reboots or resumes from hibernation. This directly addresses the challenge of scheduled tasks and unattended reboots on systems with BitLocker pre-boot PIN enabled.
|
||
|
||
## BitLocker Network Unlock Solution
|
||
|
||
Network Unlock allows systems that meet the hardware requirements and have BitLocker enabled with TPM+PIN to boot into Windows without user intervention. It requires direct ethernet connectivity to a Windows Deployment Services (WDS) server.
|
||
|
||
## TPM-Only vs. TPM+PIN for Unattended Scenarios
|
||
|
||
The only supported silent configuration for BitLocker involves the TPM only. This suggests that for true unattended automated reboots on headless servers, TPM-only protection (without PIN) is the recommended approach.
|
||
|
||
## Policy Conflicts
|
||
|
||
The search results also mention that conflicts can occur when using MDM and GPO settings together, which could be relevant if you're managing autologon policies and BitLocker policies that may not align properly.
|
||
|
||
If you're dealing with a headless server scenario requiring unattended reboots, the TPM-only configuration would be more suitable than adding a pre-boot PIN, or you would need to implement BitLocker Network Unlock to bypass the PIN requirement during automated reboots.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #27] Claude Code headless mode "claude -p" --output-format json scheduled task cron non-interactive docs
|
||
|
||
Web search results for query: "Claude Code headless mode "claude -p" --output-format json scheduled task cron non-interactive docs"
|
||
|
||
Links: [{"title":"What Is Claude Code Headless Mode? How to Run AI Agents Without a Terminal | MindStudio","url":"https://www.mindstudio.ai/blog/claude-code-headless-mode-autonomous-agents"},{"title":"Claude Code Can Work While You Sleep | wmedia.es","url":"https://wmedia.es/en/tips/claude-code-headless-mode-autonomous-agent"},{"title":"Background Claude — Run Claude Code in the background | headless, scheduled, agentic","url":"https://backgroundclaude.com/"},{"title":"Claude Code Headless Mode: The Complete Self-Hosting Guide (2026) — amux","url":"https://amux.io/guides/claude-code-headless/"},{"title":"How to Set Up Cron Jobs with Claude Code (Automated Scheduling Guide) - Usagebar Blog","url":"https://usagebar.com/blog/how-to-do-cron-job-setup-on-claude-code"},{"title":"Claude Code Automation: Non-Interactive Mode | DevShelfHub","url":"https://www.devshelfhub.com/tutorials/claude-code/automation/"},{"title":"Claude Code Headless Mode Guide (2026) | Like One","url":"https://likeone.ai/blog/claude-code-headless-mode-guide-2026/"},{"title":"Claude Code Headless Mode: The -p Flag | AI Skill Certs","url":"https://aiskillcerts.com/concepts/claude-code-config/the-p-flag-for-non-interactive-mode"},{"title":"Claude Code Headless Mode | Build This Now","url":"https://www.buildthisnow.com/blog/guide/development/claude-code-headless-mode"}]
|
||
|
||
Based on the web search results, here's what I found about Claude Code headless mode with the features you mentioned:
|
||
|
||
## Claude Code Headless Mode Overview
|
||
|
||
Claude Code headless mode uses the -p flag to run tasks non-interactively, making it suitable for automation and scheduled workflows. When you pass --print (or -p) with a prompt, Claude Code runs the task, prints output to stdout, and exits with a zero or non-zero exit code depending on success.
|
||
|
||
## Using with Scheduled Tasks and Cron
|
||
|
||
With the -p (print) flag, it becomes a headless agent you can launch from scripts, CI/CD pipelines, or — here's where it gets interesting — from a cron job. Wrap claude -p in a crontab line for nightly audits, dependency scans, or report generation; use the /loop command to repeat a prompt within a session; or drop the same command into a CI/CD pipeline step.
|
||
|
||
## Output Format (JSON)
|
||
|
||
claude -p runs a single task headlessly so Claude behaves like any Unix command · Pipe logs, diffs, file lists, and git output into Claude as context · --output-format json and --stream make output machine-parseable · Schedule with cron and guard with exit-code checks for reliable automation
|
||
|
||
## Key Characteristics
|
||
|
||
Use headless mode when you want "Claude Code, but scripted" — CI review steps, git hooks, cron jobs that run a fixed task against your existing codebase. Running Claude Code in the background means running it non-interactively — without the TUI and without a human in the loop for each step. Three surfaces exist: headless mode with claude -p for one-shot scripted calls, scheduled recurring runs via cron or the /loop command
|
||
|
||
The documentation shows that Claude Code's headless mode is designed specifically for automation scenarios where you need non-interactive execution without a terminal UI present.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #28] msg.exe send message to logged on user from scheduled task SYSTEM Windows 11 "msg * "
|
||
|
||
Web search results for query: "msg.exe send message to logged on user from scheduled task SYSTEM Windows 11 "msg * ""
|
||
|
||
Links: [{"title":"The Windows Process Journey — “msg.exe” (Message Utility) | by Shlomi Boutnaru, Ph.D. | Medium","url":"https://medium.com/@boutnaru/the-windows-process-journey-msg-exe-message-utility-a241640c365c"},{"title":"msg.exe | Message Utility | STRONTIC","url":"https://strontic.github.io/xcyclopedia/library/msg.exe-200850BBE6A2DE88A212E0E86C3FF845.html"},{"title":"Active Directory: Send Messages to all currently logged on Users (msg.exe) – SID-500.COM","url":"https://sid-500.com/2017/10/07/active-directory-send-messages-to-all-currently-logged-on-users-msg-exe/comment-page-1/"},{"title":"Display message on screen as was done in Win7 thru Task Scheduler | Windows 11 Forum","url":"https://www.elevenforum.com/t/display-message-on-screen-as-was-done-in-win7-thru-task-scheduler.16861/"},{"title":"[Fix] Can’t Create Tasks to Display Messages in Task Scheduler in Windows 8 and Later","url":"https://www.askvg.com/fix-cant-create-tasks-to-display-messages-in-windows-8-task-scheduler/"},{"title":"msg | Microsoft Learn","url":"https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msg"},{"title":"Msg command how to, how to send messages via msg command","url":"https://www.cezeo.com/tips-and-tricks/msg-command/"},{"title":"Run Scheduled Task as SYSTEM only when user is logged in","url":"https://learn.microsoft.com/en-us/answers/questions/259563/run-scheduled-task-as-system-only-when-user-is-log"},{"title":"www.oreilly.com","url":"https://www.oreilly.com/library/view/windows-xp-in/0596009003/re122.html"},{"title":"Why does my scheduled task sit queued until the first time someone logs in?","url":"https://learn.microsoft.com/en-us/answers/a/1082877"}]
|
||
|
||
I've completed a web search for your query about using msg.exe to send messages to logged-on users from a scheduled task running as SYSTEM in Windows 11. Here are the key findings:
|
||
|
||
## Basic msg.exe Functionality
|
||
|
||
msg.exe is the "Message Utility" which is a command line which allows sending a message to a user. The asterisk (*) sends a message to all sessions on the specified server.
|
||
|
||
## How to Use msg.exe with Task Scheduler
|
||
|
||
You can use schtasks to create a scheduled task that runs msg.exe, for example: `schtasks /create /sc WEEKLY /tn "BackupReminder" /tr "msg.exe * 'Backup scheduled at 7:00PM. Be sure Passport drive and AC power are plugged in!'" /d THU /st 18:45`
|
||
|
||
## Important Permissions and Requirements
|
||
|
||
The user must have Message access permission for the session to be able to send messages via msg command. Additionally, the registry key AllowRemoteRPC should have a value of 1, and if the value is not 1, it should be changed to 1.
|
||
|
||
## Edition Compatibility
|
||
|
||
The MSG command is only available to versions of Windows that are NOT the "Home" version, such as Pro/Enterprise.
|
||
|
||
The search results indicate that msg.exe can be used in scheduled tasks for Windows 11, though there may be permission and registry configuration requirements when running as SYSTEM.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [FETCH #19] https://raw.githubusercontent.com/Windos/BurntToast/main/docs/New-BTButton.md
|
||
**ASK:** Give the syntax and parameters of New-BTButton (Content, Arguments, ActivationType and its accepted values, Snooze, Dismiss, ImageUri, Id, Color) and the examples verbatim.
|
||
|
||
The server returned HTTP 404 Not Found.
|
||
|
||
The response body was not retrieved. If this URL requires authentication, use an authenticated tool (e.g. `gh` for GitHub, or an MCP-provided fetch tool) instead of WebFetch.
|
||
|
||
## [FETCH #20] https://healthchecks.io/docs/http_api/
|
||
**ASK:** List the pinging API endpoints exactly: success ping URL, /start, /fail, /log, /{exit-status}, POST body limits, the run ID (rid) parameter, and any guidance on timeouts/retries and "Grace time"/"Period" settings.
|
||
|
||
# Healthchecks.io Pinging API Endpoints
|
||
|
||
## Core Endpoints (UUID-based)
|
||
|
||
| Action | URL |
|
||
|--------|-----|
|
||
| Success | `https://hc-ping.com/<uuid>` |
|
||
| Start | `https://hc-ping.com/<uuid>/start` |
|
||
| Failure | `https://hc-ping.com/<uuid>/fail` |
|
||
| Log | `https://hc-ping.com/<uuid>/log` |
|
||
| Exit Status | `https://hc-ping.com/<uuid>/<exit-status>` |
|
||
|
||
## Slug-based Endpoints
|
||
|
||
Replace `<uuid>` with `<ping-key>/<slug>` in any endpoint above (e.g., `https://hc-ping.com/<ping-key>/<slug>`).
|
||
|
||
## Key Parameters
|
||
|
||
**Run ID (`rid`)**: Optional UUID parameter matching start and completion pings to calculate accurate job duration. Format: `rid=123e4567-e89b-12d3-a456-426614174000`
|
||
|
||
**Create Flag (slug only)**: `create=1` automatically provisions a new check if the slug doesn't exist.
|
||
|
||
**Exit Status**: Integer 0–255; "Healthchecks.io interprets 0 as a success and all other values as a failure."
|
||
|
||
## POST Body Limits
|
||
|
||
Response includes optional `Ping-Body-Limit: <n>` header indicating maximum storable bytes per request (typically 100 kB limit per ping).
|
||
|
||
## Rate Limiting
|
||
|
||
"Do not ping a check more frequently than is necessary. If you ping a check more than 5 times per minute, some of the requests may get rate limited."
|
||
|
||
## Notable Omissions
|
||
|
||
The documentation does not address timeout recommendations, retry strategies, or configuration of "Grace time" and "Period" settings within this API reference section.
|
||
|
||
## [FETCH #21] https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create
|
||
**ASK:** List the parameters for schtasks /create: /XML, /RU, /RP, /RL, /NP, /Z, /F, /SC ONSTART, /DELAY, /RI, /DU, /K, /IT, /V1, and the notes about /XML with /RU /RP (and the case where XML already contains principal). Include the examples that use /XML and ONSTART.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: schtasks create | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create
|
||
breadcrumb_path: /windows-server/breadcrumbs/toc.json
|
||
uhfHeaderId: MSDocsHeader-WindowsServer
|
||
feedback_system: Standard
|
||
recommendations: true
|
||
ms.service: windows-server
|
||
ms.subservice: windows-commands
|
||
ms.update-cycle: 1095-days
|
||
description: Reference article for the schtasks create command to automate tasks.
|
||
ms.topic: reference
|
||
author: robinharwood
|
||
ms.author: roharwoo
|
||
ms.date: 2023-10-10T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 0feda591-bda7-75e4-3eee-f38ec06f6f17
|
||
document_version_independent_id: f9f5b2ca-d26f-dd8a-70d1-0c07b94a4dd6
|
||
updated_at: 2025-10-22T17:33:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windowsserverdocs-pr/blob/live/WindowsServerDocs/administration/windows-commands/schtasks-create.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windowsserverdocs-pr/blob/4282dd47a285a65de44c1512e8e9abd2384582a8/WindowsServerDocs/administration/windows-commands/schtasks-create.md
|
||
git_commit_id: 4282dd47a285a65de44c1512e8e9abd2384582a8
|
||
site_name: Docs
|
||
depot_name: MSDN.WindowsServerDocs-pr
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.WindowsServerDocs-pr/{branchName}{pdfName}
|
||
feedback_product_url: ''
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 7288
|
||
asset_id: administration/windows-commands/schtasks-create
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: WindowsServerDocs/administration/windows-commands/schtasks-create.md
|
||
cmProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/c6f99e62-1cf6-4b71-af9b-649b05f80cce
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/86a4b315-a9f1-4577-b985-6fb0e0e67420
|
||
spProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/3f56b378-07a9-4fa1-afe8-9889fdc77628
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/96ac410d-d052-4707-8007-df31dd0fe041
|
||
platformId: ac4c5cc1-d97f-b2db-f62a-d931369a62f7
|
||
---
|
||
|
||
# schtasks create | Microsoft Learn
|
||
|
||
Schedules a task.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
```
|
||
|
||
schtasks /create /sc <scheduletype> /tn <taskname> /tr <taskrun> [/s <computer> [/u [<domain>\]<user> [/p <password>]]] [/ru {[<domain>\]<user> | system}] [/rp <password>] [/mo <modifier>] [/d <day>[,<day>...] | *] [/m <month>[,<month>...]] [/i <idletime>] [/st <starttime>] [/ri <interval>] [{/et <endtime> | /du <duration>} [/k]] [/sd <startdate>] [/ed <enddate>] [/it] [/np] [/z] [/xml <xmlfile>] [/v1] [/f] [/rl <level>] [/delay <delaytime>] [/hresult]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Parameters
|
||
|
||
|
||
|
||
| Parameter | Description |
|
||
|
||
| --- | --- |
|
||
|
||
| /sc `<scheduletype>` | Specifies the schedule type. The valid values include:<br>- **MINUTE** - Specifies the number of minutes before the task should run.<br>- **HOURLY** - Specifies the number of hours before the task should run.<br>- **DAILY** - Specifies the number of days before the task should run.<br>- **WEEKLY** Specifies the number of weeks before the task should run.<br>- **MONTHLY** - Specifies the number of months before the task should run.<br>- **ONCE** - Specifies that that task runs once at a specified date and time.<br>- **ONSTART** - Specifies that the task runs every time the system starts. You can specify a start date, or run the task the next time the system starts.<br>- **ONLOGON** - Specifies that the task runs whenever a user (any user) logs on. You can specify a date, or run the task the next time the user logs on.<br>- **ONIDLE** - Specifies that the task runs whenever the system is idle for a specified period of time. You can specify a date, or run the task the next time the system is idle.<br>- **ONEVENT** - Specifies that the task runs based on an event that matches information from the system event log including the EventID. |
|
||
|
||
| /tn `<taskname>` | Specifies a name for the task. Each task on the system must have a unique name and must conform to the rules for file names, not exceeding 238 characters. Use quotation marks to enclose names that include spaces. To store your scheduled task in a different folder, run **/tn**`<folder name\task name>`. |
|
||
|
||
| /tr `<Taskrun>` | Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. The path name must not exceed 262 characters. If you don't add the path, **schtasks** assumes that the file is in the `<systemroot>\System32` directory. |
|
||
|
||
| /s `<computer>` | Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer. |
|
||
|
||
| /u `[<domain>]` | Runs this command with the permissions of the specified user account. The default is the permissions of the current user of the local computer. The **/u** and **/p** parameters are valid only when you use **/s**. The permissions of the specified account are used to schedule the task and to run the task. To run the task with the permissions of a different user, use the **/ru** parameter. The user account must be a member of the Administrators group on the remote computer. Also, the local computer must be in the same domain as the remote computer, or must be in a domain that is trusted by the remote computer domain. |
|
||
|
||
| /p `<password>` | Specifies the password of the user account specified in the **/u** parameter. If you use the **/u** parameter without the **/p** parameter or the password argument, schtasks will prompt you for a password. The **/u** and **/p** parameters are valid only when you use **/s**. |
|
||
|
||
| /ru {[`<domain>`]`<user>` | `system}` | Runs the task with permissions of the specified user account. By default, the task runs with the permissions of the current user of the local computer, or with the permission of the user specified by the **/u** parameter, if one is included. The **/ru** parameter is valid when scheduling tasks on local or remote computers. The valid options include:<br>- **Domain** - Specifies an alternate user account.<br>- **System** - Specifies the local System account, a highly privileged account used by the operating system and system services. |
|
||
|
||
| /rp `<password>` | Specifies the password for the existing user account, or the user account specified by the **/ru** parameter. If you don't use this parameter when specifying a user account, SchTasks.exe will prompt you for the password next time you sign in. Don't use the **/rp** parameter for tasks that run with System account credentials (**/ru System**). The System account doesn't have a password and SchTasks.exe doesn't prompt for one. |
|
||
|
||
| /mo `<modifiers>` | Specifies how often the task runs within its schedule type. The valid options include:<br>- **MINUTE** - Specifies that the task runs every <n> minutes. You can use any value between 1 - 1439 minutes. By default, this is 1 minute.<br>- **HOURLY** - Specifies that the task runs every <n> hours. You can use any value between 1 - 23 hours. By default, this is 1 hour.<br>- **DAILY** - Specifies that the task runs every <n> days. You can use any value between 1 - 365 days. By default, this is 1 day.<br>- **WEEKLY** - Specifies that the task runs every <n> weeks. You can use any value between 1 - 52 weeks. By default, this is 1 week.<br>- **MONTHLY**- Specifies that the task runs every <n> months. You can use any of the following values:<br> - A number between 1 - 12 months<br> - **LASTDAY** - To run the task on the last day of the month<br> - **FIRST, SECOND, THIRD, or FOURTH along with the `/d <day>` parameter** - Specifies the particular week and day to run the task. For example, on the third Wednesday of the month.<br>- **ONCE** - Specifies that the task runs once.<br>- **ONSTART** - Specifies that the task runs at startup.<br>- **ONLOGON** - Specifies that the task runs when the user specified by the **/ru** parameter logs on.<br>- **ONIDLE** - Specifies that the task runs after the system is idle for the number of minutes specified by the **/i** parameter |
|
||
|
||
| /d DAY[,DAY...] | Specifies how often the task runs within its schedule type. The valid options include:<br>- **WEEKLY** - Specifies that the task runs weekly by providing a value between 1-52 weeks. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or a range of [MON - SUN...]).<br>- **MONTHLY** - Specifies that the task runs weekly each month by providing a value of FIRST, SECOND, THIRD, FOURTH, LAST. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or by providing a number between 1 - 12 months. If you use this option, you can also add a specific day of the month, by providing a number between 1-31.<br> **NOTE:** The date value of 1 - 31 is valid only without the **/mo** parameter, or if the **/mo** parameter is monthly (1 - 12). The default is day 1 (the first day of the month). |
|
||
|
||
| /m MONTH[,MONTH...] | Specifies a month or months of the year during which the scheduled task should run. The valid options include JAN - DEC and `*` (every month). The **/m** parameter is valid only with a MONTHLY schedule. It's required when the LASTDAY modifier is used. Otherwise, it's optional and the default value is `*` (every month). |
|
||
|
||
| /i `<Idletime>` | Specifies how many minutes the computer is idle before the task starts. A valid value is a whole number from 1 to 999. This parameter is valid only with an ONIDLE schedule, and then it's required. |
|
||
|
||
| /st `<Starttime>` | Specifies the start time for the task, using the 24-hour time format, HH:mm. The default value is the current time on the local computer. The **/st** parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It's required for a ONCE schedule. |
|
||
|
||
| /ri `<interval>` | Specifies the repetition interval for the scheduled task, in minutes. This isn't applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON,ONIDLE, and ONEVENT. Valid range is 1 - 599940 (599940 minutes = 9999 hours). If either the **/et** or **/du** parameters are specified, the default is **10 minutes**. |
|
||
|
||
| /et `<endtime>` | Specifies the time of day that a minute or hourly task schedule ends in <HH:MM> 24-hour format. After the specified end time, schtasks does not start the task again until the start time recurs. By default, task schedules have no end time. This parameter is optional and valid only with a MINUTE or HOURLY schedule. |
|
||
|
||
| /du `<duration>` | Specifies a maximum length of time for a minute or hourly schedule in <HHHH:MM> 24-hour format. After the specified time elapses, schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule. |
|
||
|
||
| /k | Stops the program that the task runs at the time specified by **/et** or **/du**. Without **/k**, schtasks doesn't start the program again after it reaches the time specified by **/et** or **/du** nor does it stop the program if it's still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule. |
|
||
|
||
| /sd `<Startdate>` | Specifies the date on which the task schedule starts. The default value is the current date on the local computer. The format for **Startdate** varies with the locale selected for the local computer in **Regional and Language Options**. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for **Short date** in **Regional and Language Options** on the local computer):<br>- `<MM>//` - Specifies to use month-first formats, such as English (United States) and Spanish (Panama).<br>- `<DD>//` - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands).<br>- `<YYYY>//` - Specifies to use for year-first formats, such as Swedish and French (Canada). |
|
||
|
||
| /ed `<Enddate>` | Specifies the date on which the schedule ends. This parameter is optional. It isn't valid in a ONCE, ONSTART, ONLOGON, ONIDLE, or ONEVENT schedule. By default, schedules have no ending date. The default value is the current date on the local computer. The format for **Enddate** varies with the locale selected for the local computer in **Regional and Language Options**. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for **Short date** in **Regional and Language Options** on the local computer):<br>- `<MM>//` - Specifies to use month-first formats, such as English (United States) and Spanish (Panama).<br>- `<DD>//` - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands).<br>- `<YYYY>//` - Specifies to use for year-first formats, such as Swedish and French (Canada). |
|
||
|
||
| /ec `<channelname>` | Specifies the event channel name triggered by the ONEVENT schedule type that matches a system event log criteria. |
|
||
|
||
| /it | Specifies to run the scheduled task only when the run as user (the user account under which the task runs) is logged on to the computer. This parameter has no effect on tasks that run with system permissions or tasks that already have the interactive-only property set. You can't use a change command to remove the interactive-only property from a task. By default, run as user is the current user of the local computer when the task is scheduled or the account specified by the **/u** parameter, if one is used. However, if the command includes the **/ru** parameter, then the run as user is the account specified by the **/ru** parameter. |
|
||
|
||
| /np | No password is stored. The task runs non-interactively as the given user. Only local resources are available. |
|
||
|
||
| /z | Specifies to delete the task upon the completion of its schedule. |
|
||
|
||
| /xml `<xmlfile>` | Creates a task specified in the XML file. Can be combined with the **/ru**
|
||
…[truncated 34721 chars]
|
||
|
||
## [FETCH #22] https://github.com/microsoft/playwright/issues/20242
|
||
**ASK:** Summarize the issue: what the user did (NSSM service, chromium not visible), the maintainers' response, and whether headless mode works under a service. Quote key sentences.
|
||
|
||
# GitHub Issue Summary: Chromium Window Not Displaying in NSSM Service
|
||
|
||
## User's Problem
|
||
The user reported that when running Playwright directly, the Chromium browser window displays normally. However, after scheduling the script through a Windows batch file and creating a service using NSSM (Non-Sucking Service Manager), the browser executes successfully but the window remains invisible.
|
||
|
||
## Key Issue Details
|
||
**What was done:** The user created a `.bat` file containing `@python a.py` and `@pause`, then wrapped it as a Windows service using NSSM. While the Playwright automation runs without errors, "the window doesn't show up" despite needing visibility.
|
||
|
||
## Notable Quote
|
||
"the playwright browser runs planned and everything goes fine except the window doesn't show up. But I need to see the window."
|
||
|
||
## Maintainers' Response
|
||
The page content provided does not include any responses from maintainers or discussion threads, only the initial issue description and repository metadata.
|
||
|
||
## Headless Mode Under Service
|
||
No information regarding headless mode behavior under service execution is included in the available content.
|
||
|
||
## [FETCH #23] https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-error-and-success-constants
|
||
**ASK:** List the constants with hex values and descriptions, especially SCHED_S_TASK_READY (0x41300), SCHED_S_TASK_RUNNING (0x41301), SCHED_S_TASK_DISABLED (0x41302), SCHED_S_TASK_HAS_NOT_RUN (0x41303), SCHED_S_TASK_NO_MORE_RUNS, SCHED_S_TASK_NOT_SCHEDULED (0x41305), SCHED_S_TASK_TERMINATED (0x41306), SCHED_S_TASK_QUEUED (0x41325), SCHED_E_ACCOUNT_INFORMATION_NOT_SET (0x8004130F), SCHED_E_TASK_NOT_RUNNING
|
||
…[truncated 109 chars]
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Task Scheduler error and success constants (WinError.h) - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-error-and-success-constants
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: If an error occurs, the Task Scheduler APIs can return one of the following error codes as an HRESULT value.
|
||
ms.assetid: 54278bbd-7dca-438e-a771-5fcb08c4aa68
|
||
keywords:
|
||
- Task Scheduler Task Scheduler , reference, error and success constants
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- SCHED_S_TASK_READY
|
||
- SCHED_S_TASK_RUNNING
|
||
- SCHED_S_TASK_DISABLED
|
||
- SCHED_S_TASK_HAS_NOT_RUN
|
||
- SCHED_S_TASK_NO_MORE_RUNS
|
||
- SCHED_S_TASK_NOT_SCHEDULED
|
||
- SCHED_S_TASK_TERMINATED
|
||
- SCHED_S_TASK_NO_VALID_TRIGGERS
|
||
- SCHED_S_EVENT_TRIGGER
|
||
- SCHED_E_TRIGGER_NOT_FOUND
|
||
- SCHED_E_TASK_NOT_READY
|
||
- SCHED_E_TASK_NOT_RUNNING
|
||
- SCHED_E_SERVICE_NOT_INSTALLED
|
||
- SCHED_E_CANNOT_OPEN_TASK
|
||
- SCHED_E_INVALID_TASK
|
||
- SCHED_E_ACCOUNT_INFORMATION_NOT_SET
|
||
- SCHED_E_ACCOUNT_NAME_NOT_FOUND
|
||
- SCHED_E_ACCOUNT_DBASE_CORRUPT
|
||
- SCHED_E_NO_SECURITY_SERVICES
|
||
- SCHED_E_UNKNOWN_OBJECT_VERSION
|
||
- SCHED_E_UNSUPPORTED_ACCOUNT_OPTION
|
||
- SCHED_E_SERVICE_NOT_RUNNING
|
||
- SCHED_E_UNEXPECTEDNODE
|
||
- SCHED_E_NAMESPACE
|
||
- SCHED_E_INVALIDVALUE
|
||
- SCHED_E_MISSINGNODE
|
||
- SCHED_E_MALFORMEDXML
|
||
- SCHED_S_SOME_TRIGGERS_FAILED
|
||
- SCHED_S_BATCH_LOGON_PROBLEM
|
||
- SCHED_E_TOO_MANY_NODES
|
||
- SCHED_E_PAST_END_BOUNDARY
|
||
- SCHED_E_ALREADY_RUNNING
|
||
- SCHED_E_USER_NOT_LOGGED_ON
|
||
- SCHED_E_INVALID_TASK_HASH
|
||
- SCHED_E_SERVICE_NOT_AVAILABLE
|
||
- SCHED_E_SERVICE_TOO_BUSY
|
||
- SCHED_E_TASK_ATTEMPTED
|
||
- SCHED_S_TASK_QUEUED
|
||
- SCHED_E_TASK_DISABLED
|
||
- SCHED_E_TASK_NOT_V1_COMPAT
|
||
- SCHED_E_START_ON_DEMAND
|
||
api_location:
|
||
- WinError.h
|
||
api_type:
|
||
- HeaderDef
|
||
ms.topic: reference
|
||
ms.custom: snippet-project
|
||
ms.date: 2024-10-29T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: d95e7531-e18c-2d02-2a0f-bd9fa9f3418a
|
||
document_version_independent_id: 4e74a49f-b001-001a-5582-8b214d32d072
|
||
updated_at: 2024-10-29T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/task-scheduler-error-and-success-constants.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/008b6856680c0435cbb8b3761d128e84cf3a82ce/desktop-src/TaskSchd/task-scheduler-error-and-success-constants.md
|
||
git_commit_id: 008b6856680c0435cbb8b3761d128e84cf3a82ce
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 850
|
||
asset_id: taskschd/task-scheduler-error-and-success-constants
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/task-scheduler-error-and-success-constants.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/540ac133-a371-4dbb-8f94-28d6cc77a70b
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/60bfc045-f127-4841-9d00-ea35495a5800
|
||
platformId: 79c8da83-2ebd-c4eb-e12a-0e6eb4ab948f
|
||
---
|
||
|
||
# Task Scheduler error and success constants (WinError.h) - Win32 apps | Microsoft Learn
|
||
|
||
If an error occurs, the Task Scheduler APIs can return one of the following error codes as an **HRESULT** value.
|
||
|
||
|
||
|
||
The constants that begin with SCHED\_S\_ are success constants, and the constants that begin with SCHED\_E\_ are error constants.
|
||
|
||
|
||
|
||
```cpp
|
||
|
||
HRESULT phrStatus;
|
||
|
||
hr = pITask->GetStatus(&phrStatus);
|
||
|
||
|
||
|
||
// Release the ITask interface.
|
||
|
||
pITask->Release();
|
||
|
||
|
||
|
||
switch(phrStatus)
|
||
|
||
{
|
||
|
||
case SCHED_S_TASK_READY:
|
||
|
||
wprintf(L" SCHED_S_TASK_READY\n");
|
||
|
||
break;
|
||
|
||
case SCHED_S_TASK_RUNNING:
|
||
|
||
wprintf(L" SCHED_S_TASK_RUNNING\n");
|
||
|
||
break;
|
||
|
||
|
||
|
||
//...
|
||
|
||
}
|
||
|
||
```
|
||
|
||
|
||
|
||
Example from [C/C++ code example: retrieving task status](c-c-code-example-retrieving-task-status).
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
Some Task Scheduler APIs can return system and network error codes (64 for example). You can check the definition of these types of error codes by using the **net helpmsg** command in the command prompt window. For example, the command **net helpmsg 64** returns the message: The specified network name is no longer available.
|
||
|
||
|
||
|
||
For more info about events and error messages, see [Events and Errors Message Center](https://www.microsoft.com/technet/support/ee/ee_advanced.aspx).
|
||
|
||
|
||
|
||
**SCHED\_E\_SERVICE\_NOT\_LOCALSYSTEM**
|
||
|
||
|
||
|
||
The Task Scheduler service must be configured to run in the System account to function properly. Individual tasks may be configured to run in other accounts.
|
||
|
||
|
||
|
||
`#define SCHED_E_SERVICE_NOT_LOCALSYSTEM 6200L`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_READY**
|
||
|
||
|
||
|
||
The task is ready to run at its next scheduled time.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_READY _HRESULT_TYPEDEF_(0x00041300L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_RUNNING**
|
||
|
||
|
||
|
||
The task is currently running.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_RUNNING _HRESULT_TYPEDEF_(0x00041301L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_DISABLED**
|
||
|
||
|
||
|
||
The task will not run at the scheduled times because it has been disabled.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_DISABLED _HRESULT_TYPEDEF_(0x00041302L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_HAS\_NOT\_RUN**
|
||
|
||
|
||
|
||
The task has not yet run.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_HAS_NOT_RUN _HRESULT_TYPEDEF_(0x00041303L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_NO\_MORE\_RUNS**
|
||
|
||
|
||
|
||
There are no more runs scheduled for this task.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_NO_MORE_RUNS _HRESULT_TYPEDEF_(0x00041304L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_NOT\_SCHEDULED**
|
||
|
||
|
||
|
||
One or more of the properties that are needed to run this task on a schedule have not been set.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_NOT_SCHEDULED _HRESULT_TYPEDEF_(0x00041305L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_TERMINATED**
|
||
|
||
|
||
|
||
The last run of the task was terminated by the user.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_TERMINATED _HRESULT_TYPEDEF_(0x00041306L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_NO\_VALID\_TRIGGERS**
|
||
|
||
|
||
|
||
Either the task has no triggers or the existing triggers are disabled or not set.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_NO_VALID_TRIGGERS _HRESULT_TYPEDEF_(0x00041307L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_EVENT\_TRIGGER**
|
||
|
||
|
||
|
||
Event triggers don't have set run times.
|
||
|
||
|
||
|
||
`#define SCHED_S_EVENT_TRIGGER _HRESULT_TYPEDEF_(0x00041308L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TRIGGER\_NOT\_FOUND**
|
||
|
||
|
||
|
||
Trigger not found.
|
||
|
||
|
||
|
||
`#define SCHED_E_TRIGGER_NOT_FOUND _HRESULT_TYPEDEF_(0x80041309L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_NOT\_READY**
|
||
|
||
|
||
|
||
One or more of the properties that are needed to run this task have not been set.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_NOT_READY _HRESULT_TYPEDEF_(0x8004130AL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_NOT\_RUNNING**
|
||
|
||
|
||
|
||
There is no running instance of the task.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_NOT_RUNNING _HRESULT_TYPEDEF_(0x8004130BL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_SERVICE\_NOT\_INSTALLED**
|
||
|
||
|
||
|
||
The Task Scheduler Service is not installed on this computer.
|
||
|
||
|
||
|
||
`#define SCHED_E_SERVICE_NOT_INSTALLED _HRESULT_TYPEDEF_(0x8004130CL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_CANNOT\_OPEN\_TASK**
|
||
|
||
|
||
|
||
The task object could not be opened.
|
||
|
||
|
||
|
||
`#define SCHED_E_CANNOT_OPEN_TASK _HRESULT_TYPEDEF_(0x8004130DL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_INVALID\_TASK**
|
||
|
||
|
||
|
||
The object is either an invalid task object or is not a task object.
|
||
|
||
|
||
|
||
`#define SCHED_E_INVALID_TASK _HRESULT_TYPEDEF_(0x8004130EL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_ACCOUNT\_INFORMATION\_NOT\_SET**
|
||
|
||
|
||
|
||
No account information could be found in the Task Scheduler security database for the task indicated.
|
||
|
||
|
||
|
||
`#define SCHED_E_ACCOUNT_INFORMATION_NOT_SET _HRESULT_TYPEDEF_(0x8004130FL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_ACCOUNT\_NAME\_NOT\_FOUND**
|
||
|
||
|
||
|
||
Unable to establish existence of the account specified.
|
||
|
||
|
||
|
||
`#define SCHED_E_ACCOUNT_NAME_NOT_FOUND _HRESULT_TYPEDEF_(0x80041310L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_ACCOUNT\_DBASE\_CORRUPT**
|
||
|
||
|
||
|
||
Corruption was detected in the Task Scheduler security database; the database has been reset.
|
||
|
||
|
||
|
||
`#define SCHED_E_ACCOUNT_DBASE_CORRUPT _HRESULT_TYPEDEF_(0x80041311L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_NO\_SECURITY\_SERVICES**
|
||
|
||
|
||
|
||
Task Scheduler security services are available only on Windows NT.
|
||
|
||
|
||
|
||
`#define SCHED_E_NO_SECURITY_SERVICES _HRESULT_TYPEDEF_(0x80041312L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_UNKNOWN\_OBJECT\_VERSION**
|
||
|
||
|
||
|
||
The task object version is either unsupported or invalid.
|
||
|
||
|
||
|
||
`#define SCHED_E_UNKNOWN_OBJECT_VERSION _HRESULT_TYPEDEF_(0x80041313L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_UNSUPPORTED\_ACCOUNT\_OPTION**
|
||
|
||
|
||
|
||
The task has been configured with an unsupported combination of account settings and run time options.
|
||
|
||
|
||
|
||
`#define SCHED_E_UNSUPPORTED_ACCOUNT_OPTION _HRESULT_TYPEDEF_(0x80041314L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_SERVICE\_NOT\_RUNNING**
|
||
|
||
|
||
|
||
The Task Scheduler Service is not running.
|
||
|
||
|
||
|
||
`#define SCHED_E_SERVICE_NOT_RUNNING _HRESULT_TYPEDEF_(0x80041315L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_UNEXPECTEDNODE**
|
||
|
||
|
||
|
||
The task XML contains an unexpected node.
|
||
|
||
|
||
|
||
`#define SCHED_E_UNEXPECTEDNODE _HRESULT_TYPEDEF_(0x80041316L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_NAMESPACE**
|
||
|
||
|
||
|
||
The task XML contains an element or attribute from an unexpected namespace.
|
||
|
||
|
||
|
||
`#define SCHED_E_NAMESPACE _HRESULT_TYPEDEF_(0x80041317L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_INVALIDVALUE**
|
||
|
||
|
||
|
||
The task XML contains a value which is incorrectly formatted or out of range.
|
||
|
||
|
||
|
||
`#define SCHED_E_INVALIDVALUE _HRESULT_TYPEDEF_(0x80041318L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_MISSINGNODE**
|
||
|
||
|
||
|
||
The task XML is missing a required element or attribute.
|
||
|
||
|
||
|
||
`#define SCHED_E_MISSINGNODE _HRESULT_TYPEDEF_(0x80041319L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_MALFORMEDXML**
|
||
|
||
|
||
|
||
The task XML is malformed.
|
||
|
||
|
||
|
||
`#define SCHED_E_MALFORMEDXML _HRESULT_TYPEDEF_(0x8004131AL)`
|
||
|
||
|
||
|
||
**SCHED\_S\_SOME\_TRIGGERS\_FAILED**
|
||
|
||
|
||
|
||
The task is registered, but not all specified triggers will start the task, check task scheduler event log for detailed information.
|
||
|
||
|
||
|
||
`#define SCHED_S_SOME_TRIGGERS_FAILED _HRESULT_TYPEDEF_(0x0004131BL)`
|
||
|
||
|
||
|
||
**SCHED\_S\_BATCH\_LOGON\_PROBLEM**
|
||
|
||
|
||
|
||
The task is registered, but may fail to start. Batch logon privilege needs to be enabled for the task principal.
|
||
|
||
|
||
|
||
`#define SCHED_S_BATCH_LOGON_PROBLEM _HRESULT_TYPEDEF_(0x0004131CL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TOO\_MANY\_NODES**
|
||
|
||
|
||
|
||
The task XML contains too many nodes of the same type.
|
||
|
||
|
||
|
||
`#define SCHED_E_TOO_MANY_NODES _HRESULT_TYPEDEF_(0x8004131DL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_PAST\_END\_BOUNDARY**
|
||
|
||
|
||
|
||
The task cannot be started after the trigger's end boundary.
|
||
|
||
|
||
|
||
`#define SCHED_E_PAST_END_BOUNDARY _HRESULT_TYPEDEF_(0x8004131EL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_ALREADY\_RUNNING**
|
||
|
||
|
||
|
||
An instance of this task is already running.
|
||
|
||
|
||
|
||
`#define SCHED_E_ALREADY_RUNNING _HRESULT_TYPEDEF_(0x8004131FL)`
|
||
|
||
|
||
|
||
**SCHED\_E\_USER\_NOT\_LOGGED\_ON**
|
||
|
||
|
||
|
||
The task will not run because the user is not logged on.
|
||
|
||
|
||
|
||
`#define SCHED_E_USER_NOT_LOGGED_ON _HRESULT_TYPEDEF_(0x80041320L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_INVALID\_TASK\_HASH**
|
||
|
||
|
||
|
||
The task image is corrupt or has been tampered with.
|
||
|
||
|
||
|
||
`#define SCHED_E_INVALID_TASK_HASH _HRESULT_TYPEDEF_(0x80041321L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_SERVICE\_NOT\_AVAILABLE**
|
||
|
||
|
||
|
||
The Task Scheduler service is not available.
|
||
|
||
|
||
|
||
`#define SCHED_E_SERVICE_NOT_AVAILABLE _HRESULT_TYPEDEF_(0x80041322L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_SERVICE\_TOO\_BUSY**
|
||
|
||
|
||
|
||
The Task Scheduler service is too busy to handle your request. Please try again later.
|
||
|
||
|
||
|
||
`#define SCHED_E_SERVICE_TOO_BUSY _HRESULT_TYPEDEF_(0x80041323L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_ATTEMPTED**
|
||
|
||
|
||
|
||
The Task Scheduler service attempted to run the task, but the task did not run due to one of the constraints in the task definition.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_ATTEMPTED _HRESULT_TYPEDEF_(0x80041324L)`
|
||
|
||
|
||
|
||
**SCHED\_S\_TASK\_QUEUED**
|
||
|
||
|
||
|
||
The Task Scheduler service has asked the task to run.
|
||
|
||
|
||
|
||
`#define SCHED_S_TASK_QUEUED _HRESULT_TYPEDEF_(0x00041325L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_DISABLED**
|
||
|
||
|
||
|
||
The task is disabled.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_DISABLED _HRESULT_TYPEDEF_(0x80041326L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_NOT\_V1\_COMPAT**
|
||
|
||
|
||
|
||
The task has properties that are not compatible with previous versions of Windows.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_NOT_V1_COMPAT _HRESULT_TYPEDEF_(0x80041327L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_START\_ON\_DEMAND**
|
||
|
||
|
||
|
||
The task settings do not allow the task to start on demand.
|
||
|
||
|
||
|
||
`#define SCHED_E_START_ON_DEMAND _HRESULT_TYPEDEF_(0x80041328L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_TASK\_NOT\_UBPM\_COMPAT**
|
||
|
||
|
||
|
||
The combination of properties that task is using is not compatible with the scheduling engine.
|
||
|
||
|
||
|
||
`#define SCHED_E_TASK_NOT_UBPM_COMPAT _HRESULT_TYPEDEF_(0x80041329L)`
|
||
|
||
|
||
|
||
**SCHED\_E\_DEPRECATED\_FEATURE\_USED**
|
||
|
||
|
||
|
||
The task definition uses a deprecated feature.
|
||
|
||
|
||
|
||
`#define SCHED_E_DEPRECATED_FEATURE_USED _HRESULT_TYPEDEF_(0x80041330L)`
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
| Header | WinError.h |
|
||
|
||
## [FETCH #24] https://learn.microsoft.com/en-us/troubleshoot/windows-client/deployment/fast-startup-causes-system-hibernation-shutdown-fail
|
||
**ASK:** Summarize what Fast Startup is, what it does on shutdown (hibernation of kernel session), the consequences (services/tasks that expect a real boot, updates), and how to disable it (registry HiberbootEnabled, powercfg /h off, Control Panel). Include exact registry path/value if present.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Fast startup causes hibernation or shutdown to fail in Windows 10 or Windows 8.1 - Windows Client | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/troubleshoot/windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail
|
||
breadcrumb_path: /support/breadcrumb/toc.json
|
||
feedback_system: Standard
|
||
recommendations: true
|
||
uhfHeaderId: MSDocsHeader-Windows
|
||
feedback_product_url: https://support.microsoft.com/windows/f59187f8-8739-22d6-ba93-f66612949332
|
||
manager: dcscontentpm
|
||
audience: itpro
|
||
author: kaushika-msft
|
||
ms.author: kaushika
|
||
ms.topic: troubleshooting
|
||
ms.service: windows-client
|
||
description: Provides help to solve an issue where the process fails when you try to shut down or hibernate the system on a computer.
|
||
ms.date: 2026-02-12T00:00:00.0000000Z
|
||
ms.reviewer: kaushika
|
||
ms.custom:
|
||
- sap:windows setup,upgrade and deployment\power management
|
||
- pcy:WinComm Devices Deploy
|
||
locale: en-us
|
||
document_id: dfdd043b-91d3-77e7-3d4d-1559ce63155a
|
||
document_version_independent_id: 214e0d56-3c0f-bc6b-fa70-38b8552c8bf0
|
||
updated_at: 2026-02-19T02:04:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/SupportArticles-docs-pr/blob/live/support/windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail.md
|
||
gitcommit: https://github.com/MicrosoftDocs/SupportArticles-docs-pr/blob/9d838d1e92fb6151de038f6ccde0f1987bf6758a/support/windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail.md
|
||
git_commit_id: 9d838d1e92fb6151de038f6ccde0f1987bf6758a
|
||
site_name: Docs
|
||
depot_name: MSDN.support1-docset
|
||
page_type: conceptual
|
||
toc_rel: ../toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.support1-docset/{branchName}{pdfName}
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 600
|
||
asset_id: windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: support/windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/e0ffb20c-01c6-407b-a9bd-29111652a1dc
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/3904bce4-d817-48cf-85fd-b6146fca83b7
|
||
platformId: 27176170-c961-47f1-a1bd-2cbfd4dc81d2
|
||
---
|
||
|
||
# Fast startup causes hibernation or shutdown to fail in Windows 10 or Windows 8.1 - Windows Client | Microsoft Learn
|
||
|
||
This article provides help to solve an issue where the process fails when you try to shut down or hibernate the system on a computer.
|
||
|
||
|
||
|
||
*Applies to:* Windows 10 - all editions*Original KB number:* 3211190
|
||
|
||
|
||
|
||
## Symptoms
|
||
|
||
|
||
|
||
When you try to shut down or hibernate the system on a computer that's running Windows 10 or Windows 8.1, the process fails and reverts to the Windows Lock screen.
|
||
|
||
|
||
|
||
Additionally, when you go to the **Details** tab in this event and then select friendly view, you may notice the following:
|
||
|
||
|
||
|
||
>
|
||
|
||
> Binary data:
|
||
|
||
>
|
||
|
||
> In Words
|
||
|
||
>
|
||
|
||
> 0000: 00000000 00000001 00000000 C004002D 0010: 00002005 C0000034 00000000 00000000 0020: 00000000 00000000
|
||
|
||
>
|
||
|
||
> C0000034 - means STATUS\_OBJECT\_NAME\_NOT\_FOUND
|
||
|
||
>
|
||
|
||
> C004002D - means IO\_DUMP\_DRIVER\_LOAD\_FAILURE
|
||
|
||
|
||
|
||
## Cause
|
||
|
||
|
||
|
||
This issue may occur if Fast Startup is enabled under **Control Panel\All Control Panel Items\Power Options\System Settings**. When Fast Startup is enabled and a user shuts down the computer, all sessions are logged off, and the computer enters hibernation. As part of the hibernation process, Windows initializes the system's memory dump configuration. If the driver is not loaded, it fails to hibernate, and the event that's mentioned in the Symptoms section is logged. This brings you back to the Windows Lock screen.
|
||
|
||
|
||
|
||
## Resolution
|
||
|
||
|
||
|
||
Important
|
||
|
||
|
||
|
||
This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, see [How to back up and restore the registry in Windows](https://support.microsoft.com/help/322756).
|
||
|
||
|
||
|
||
To resolve this issue, check whether event ID 45 is logged in the System log. If you see this event, verify the contents under the DumpFilters registry value:
|
||
|
||
|
||
|
||
1. Open the **Run** box. To do this, press the Windows logo key + R.
|
||
|
||
2. Type *regedit*, and then press Enter.
|
||
|
||
3. Locate and click the following registry entry:`HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\CrashControl\`
|
||
|
||
4. From the pane on the right, verify the contents under the DumpFilters registry value.
|
||
|
||
5. Remove everything and make sure that dumpfve.sys is the only value listed.
|
||
|
||
6. Exit Registry editor.
|
||
|
||
7. Restart the computer to enable Fast Startup.
|
||
|
||
|
||
|
||
## Workaround
|
||
|
||
|
||
|
||
If you want to shut down the computer without using the Hybrid Shutdown behavior, you can use Shutdown.exe instead. Full shutdown is the default when you use Shutdown.exe, as follows:
|
||
|
||
|
||
|
||
```console
|
||
|
||
Shutdown /s /t 0
|
||
|
||
```
|
||
|
||
|
||
|
||
The Shutdown.exe command also includes an optional `/hybrid` parameter that can be used if you want to use the new method:
|
||
|
||
|
||
|
||
```console
|
||
|
||
Shutdown /s /hybrid /t 0
|
||
|
||
```
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
- The Fast Startup setting doesn't apply to Restart.
|
||
|
||
- Fast Startup is enabled by default in Windows.
|
||
|
||
- Disabling Fast Startup is not recommended.
|
||
|
||
|
||
|
||
## More information
|
||
|
||
|
||
|
||
During Fast Startup, the kernel session is not closed, but it is hibernated. Fast Startup is a setting that helps the computer start faster after shutdown. Windows does this by saving the kernel session and device drivers (system information) to the hibernate (hiberfil.sys) file on disk instead of closing it when you shut down the computer.
|
||
|
||
|
||
|
||
When you restart the computer, this typically means that you want a completely new Windows state, either because you have installed a driver or replaced Windows elements that cannot be replaced without a full restart.
|
||
|
||
|
||
|
||
Therefore, the restart process in Windows continues to perform a full boot cycle, without the hibernation performance improvement that's described in this article.
|
||
|
||
|
||
|
||
## Data collection
|
||
|
||
|
||
|
||
If you need assistance from Microsoft support, we recommend you collect the information by following the steps mentioned in [Gather information by using TSS for deployment-related issues](../windows-troubleshooters/gather-information-using-tss-deployment).
|
||
|
||
## [FETCH #25] https://learn.microsoft.com/en-us/windows/win32/taskschd/task-security-context
|
||
**ASK:** Summarize the page: what security context tasks run under, the difference between interactive token logon (user must be logged on, task visible) and password/S4U logon (runs whether logged on or not, non-interactive, cannot display UI), the rule on 'run with highest privileges', and any notes on network access for S4U.
|
||
|
||
The server returned HTTP 404 Not Found.
|
||
|
||
The response body was not retrieved. If this URL requires authentication, use an authenticated tool (e.g. `gh` for GitHub, or an MCP-provided fetch tool) instead of WebFetch.
|
||
|
||
## [FETCH #26] https://windows-toasts.readthedocs.io/
|
||
**ASK:** Summarize: install command, Python version requirement, dependency (winrt), minimal example (WindowsToaster / Toast / show_toast), how to add buttons/actions (ToastButton, on_activated callback), InteractableWindowsToaster requirement, AUMID registration/branding, and any note about running from Task Scheduler/services.
|
||
|
||
# Windows-Toasts Library Summary
|
||
|
||
Based on the documentation homepage, here's what I can determine:
|
||
|
||
**Installation & Requirements:**
|
||
The page doesn't provide the specific install command or Python version requirements—you'd need to visit the "Getting started" section for those details.
|
||
|
||
**Core Components:**
|
||
The library uses Windows SDK bindings for notifications. Key classes mentioned include `WindowsToaster`, `Toast`, and `ToastButton` for creating and displaying notifications.
|
||
|
||
**Basic Usage:**
|
||
A minimal example would involve creating a `WindowsToaster` instance and calling `show_toast()` with a `Toast` object, though the actual code isn't shown on this landing page.
|
||
|
||
**Interactive Features:**
|
||
The documentation references an "Interactable toasts" section covering buttons and actions. `ToastButton` and callback mechanisms (like `on_activated`) are indicated but not detailed here.
|
||
|
||
**Special Requirements:**
|
||
An `InteractableWindowsToaster` class is mentioned for interactive toast functionality, requiring additional setup beyond basic notifications.
|
||
|
||
**AUMID Configuration:**
|
||
Custom AUMIDs (Application User Model IDs) need registration via PowerShell or the registry for proper branding and notification delivery.
|
||
|
||
**Limitations:**
|
||
The page doesn't address Task Scheduler or service execution requirements—consult the "Problem solving" section for those concerns.
|
||
|
||
**Note:** Full implementation details require accessing the linked sections for code examples and complete specifications.
|
||
|
||
## [FETCH #27] https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-restarttype-complextype
|
||
**ASK:** Give the XSD of restartType (Interval and Count elements), their types and any min/max constraints (e.g., Interval between PT1M and PT31D, Count up to 999) and any example XML.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: restartType Complex Type - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-restarttype-complextype
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Defines the child elements and sequence information for the RestartOnFailure element.
|
||
ms.assetid: 3a192955-8a33-42b9-a974-faa9a3789f58
|
||
keywords:
|
||
- restartType complex type Task Scheduler
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- restartType
|
||
api_type:
|
||
- Schema
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
api_location:
|
||
locale: en-us
|
||
document_id: 0f2abe12-1ab8-fdc8-3a32-0c5df3e3044c
|
||
document_version_independent_id: 0cc536f6-5ccf-50bf-d9b4-4c7a6de43406
|
||
updated_at: 2020-12-11T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/taskschedulerschema-restarttype-complextype.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/2ec0df659644a793ed4f6160f238a95c9d9a9dcf/desktop-src/TaskSchd/taskschedulerschema-restarttype-complextype.md
|
||
git_commit_id: 2ec0df659644a793ed4f6160f238a95c9d9a9dcf
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 94
|
||
asset_id: taskschd/taskschedulerschema-restarttype-complextype
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/taskschedulerschema-restarttype-complextype.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: e3415a65-999d-0b41-2339-9b012cc57e95
|
||
---
|
||
|
||
# restartType Complex Type - Win32 apps | Microsoft Learn
|
||
|
||
Defines the child elements and sequence information for the [RestartOnFailure](taskschedulerschema-restartonfailure-settingstype-element) element.
|
||
|
||
|
||
|
||
```syntax
|
||
|
||
<xs:complexType name="restartType">
|
||
|
||
<xs:all>
|
||
|
||
<xs:element name="Interval">
|
||
|
||
<xs:simpleType>
|
||
|
||
<xs:restriction
|
||
|
||
base="duration"
|
||
|
||
>
|
||
|
||
<xs:minInclusive
|
||
|
||
value="PT1M"
|
||
|
||
/>
|
||
|
||
<xs:maxInclusive
|
||
|
||
value="P31D"
|
||
|
||
/>
|
||
|
||
</xs:restriction>
|
||
|
||
</xs:simpleType>
|
||
|
||
</xs:element>
|
||
|
||
<xs:element name="Count">
|
||
|
||
<xs:simpleType>
|
||
|
||
<xs:restriction
|
||
|
||
base="unsignedByte"
|
||
|
||
>
|
||
|
||
<xs:minInclusive
|
||
|
||
value="1"
|
||
|
||
/>
|
||
|
||
</xs:restriction>
|
||
|
||
</xs:simpleType>
|
||
|
||
</xs:element>
|
||
|
||
</xs:all>
|
||
|
||
</xs:complexType>
|
||
|
||
```
|
||
|
||
|
||
|
||
## Child elements
|
||
|
||
|
||
|
||
| Element | Type | Description |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| [**Count**](taskschedulerschema-count-restarttype-element) | | Number of attempts to restart the task. |
|
||
|
||
| [**Interval**](taskschedulerschema-interval-restarttype-element) | | How long to try to start the task. |
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
## [FETCH #28] https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-executiontimelimit-settingstype-element
|
||
**ASK:** Give the definition of ExecutionTimeLimit, its type/format (duration PnYnMnDTnHnMnS), default (PT72H?), and how to express 'unlimited' (PT0S) if mentioned.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: ExecutionTimeLimit (settingsType) Element - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-executiontimelimit-settingstype-element
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Amount of time allowed to complete the task.
|
||
ms.assetid: c42d0f42-4571-44ab-90b1-948fd7ea991b
|
||
keywords:
|
||
- ExecutionTimeLimit element Task Scheduler
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- ExecutionTimeLimit
|
||
api_type:
|
||
- Schema
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
api_location:
|
||
locale: en-us
|
||
document_id: 9c6185f3-bd28-34fc-ba55-0cc8c168430e
|
||
document_version_independent_id: 2dc55e22-72cf-32f2-5727-9cdf30bfce7f
|
||
updated_at: 2020-12-11T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/taskschedulerschema-executiontimelimit-settingstype-element.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/2ec0df659644a793ed4f6160f238a95c9d9a9dcf/desktop-src/TaskSchd/taskschedulerschema-executiontimelimit-settingstype-element.md
|
||
git_commit_id: 2ec0df659644a793ed4f6160f238a95c9d9a9dcf
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 170
|
||
asset_id: taskschd/taskschedulerschema-executiontimelimit-settingstype-element
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/taskschedulerschema-executiontimelimit-settingstype-element.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 97de616f-4ca4-096c-dc42-0345961282ec
|
||
---
|
||
|
||
# ExecutionTimeLimit (settingsType) Element - Win32 apps | Microsoft Learn
|
||
|
||
Amount of time allowed to complete the task.The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). For more information about the duration type, see https://go.microsoft.com/fwlink/p/?linkid=106886. A value of PT0S will enable the task to run indefinitely.
|
||
|
||
|
||
|
||
```syntax
|
||
|
||
<xs:element name="ExecutionTimeLimit"
|
||
|
||
type="duration"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
```
|
||
|
||
|
||
|
||
The **ExecutionTimeLimit** element is defined by the [**settingsType**](taskschedulerschema-settingstype-complextype) complex type.
|
||
|
||
|
||
|
||
## Parent element
|
||
|
||
|
||
|
||
| Element | Derived from | Description |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| [**Settings**](taskschedulerschema-settings-tasktype-element) | [**settingsType**](taskschedulerschema-settingstype-complextype) | Contains the settings that the Task Scheduler uses to perform the task. |
|
||
|
||
|
||
|
||
## Remarks
|
||
|
||
|
||
|
||
For C++ development, see [**ExecutionTimeLimit Property of ITaskSettings**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itasksettings-get_executiontimelimit).
|
||
|
||
|
||
|
||
For script development, see [**TaskSettings.ExecutionTimeLimit**](tasksettings-executiontimelimit).
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
## [FETCH #29] https://raw.githubusercontent.com/dahall/TaskScheduler/master/TaskService/TaskEvent.cs
|
||
**ASK:** Extract the StandardTaskEventId enum: list each event ID number and its name/meaning (e.g., 100 TaskStarted, 101 TaskStartFailed, 102 TaskCompleted, 103 ActionStartFailed, 106 TaskRegistered, 107 TaskTriggeredOnScheduler, 108 TaskTriggeredByEvent, 110 TaskTriggeredByUser, 111 TaskTerminated, 129 CreatedTaskProcess, 200 ActionStarted, 201 ActionCompleted, 202 ActionFailed, 203 ActionLaunchFailed, 3
|
||
…[truncated 77 chars]
|
||
|
||
# StandardTaskEventId Enum - Complete List
|
||
|
||
Here are all event IDs from the enum with their names and descriptions:
|
||
|
||
| ID | Name | Meaning |
|
||
|---|---|---|
|
||
| 100 | JobStart | Task Scheduler started an instance of a task |
|
||
| 101 | JobStartFailed | Task Scheduler failed to start a task |
|
||
| 102 | JobSuccess | Task completed successfully |
|
||
| 103 | JobFailure | Task execution failed |
|
||
| 104 | LogonFailure | Failed to log on the user |
|
||
| 105 | ImpersonationFailure | Failed to impersonate a user |
|
||
| 106 | JobRegistered | User registered a task |
|
||
| 107 | TimeTrigger | Task launched due to time trigger |
|
||
| 108 | EventTrigger | Task launched due to event trigger |
|
||
| 109 | ImmediateTrigger | Task launched due to registration trigger |
|
||
| 110 | Run | Task launched for a user |
|
||
| 111 | JobTermination | Task terminated for exceeding time allocation |
|
||
| 112 | JobNoStartWithoutNetwork | Network unavailable, task not started |
|
||
| 113 | TaskRegisteredWithoutSomeTriggers | Some triggers won't start the task |
|
||
| 114 | MissedTaskLaunched | Missed task started on-demand |
|
||
| 115 | TransactionRollbackFailure | Failed to roll back transaction |
|
||
| 116 | TaskRegisteredWithoutCredentials | Credentials couldn't be stored |
|
||
| 117 | IdleTrigger | Task launched due to idle condition |
|
||
| 118 | BootTrigger | Task launched due to system startup |
|
||
| 119 | LogonTrigger | Task launched due to user logon |
|
||
| 120 | ConsoleConnectTrigger | Task launched on console connection |
|
||
| 121 | ConsoleDisconnectTrigger | Task launched on console disconnection |
|
||
| 122 | RemoteConnectTrigger | Task launched on remote connection |
|
||
| 123 | RemoteDisconnectTrigger | Task launched on remote disconnection |
|
||
| 124 | SessionLockTrigger | Task launched on computer lock |
|
||
| 125 | SessionUnlockTrigger | Task launched on computer unlock |
|
||
| 126 | FailedTaskRestart | Failed task restart attempt |
|
||
| 127 | RejectedTaskRestart | Shutdown race condition restart attempt |
|
||
| 128 | IgnoredTaskStart | Task not launched—end time exceeded |
|
||
| 129 | CreatedTaskProcess | Task launched in new process |
|
||
| 130 | TaskNotRunServiceBusy | Service busy, task not started |
|
||
| 131 | TaskNotStartedTaskQueueQuotaExceeded | Task queue quota exceeded |
|
||
| 132 | TaskQueueQuotaApproaching | Queue quota approaching limit |
|
||
| 133 | TaskNotStartedEngineQuotaExceeded | Engine quota exceeded |
|
||
| 134 | EngineQuotaApproaching | Engine quota approaching limit |
|
||
| 135 | NotStartedWithoutIdle | Machine not idle, task not launched |
|
||
| 140 | TaskUpdated | User updated a task |
|
||
| 141 | TaskDeleted | User deleted a task |
|
||
| 142 | TaskDisabled | User disabled a task |
|
||
| 145 | TaskStartedOnComputerWakeup | Task started on computer wakeup |
|
||
| 150 | TaskEventSubscriptionFailed | Failed to subscribe event trigger |
|
||
| 200 | ActionStart | Task action launched |
|
||
| 201 | ActionSuccess | Task action completed successfully |
|
||
| 202 | ActionFailure | Task action failed |
|
||
| 203 | ActionLaunchFailure | Failed to launch action |
|
||
| 204 | EventRenderFailed | Failed to retrieve event values |
|
||
| 205 | EventAggregateFailed | Failed to match event pattern |
|
||
| 301 | SessionExit | Task engine shutting down |
|
||
| 303 | SessionError | Task engine shutting down due to error |
|
||
| 304 | SessionSentJob | Task sent to engine |
|
||
| 305 | SessionSentJobFailed | Task not sent to engine |
|
||
| 306 | SessionFailedToProcessMessage | Thread pool failed to process message |
|
||
| 307 | SessionManagerConnectFailed | Failed to connect to engine process |
|
||
| 308 | SessionConnected | Connected to engine process |
|
||
| 309 | SessionJobsOrphaned | Tasks orphaned during shutdown |
|
||
| 310 | SessionProcessStarted | Engine process started |
|
||
| 311 | SessionProcessLaunchFailed | Failed to start engine process |
|
||
| 312 | SessionWin32ObjectCreated | Win32 job object created |
|
||
| 313 | SessionChannelReady | Channel ready for messages |
|
||
| 314 | SessionIdle | No tasks running, idle timer started |
|
||
| 315 | SessionProcessConnectFailed | Engine failed to connect to service |
|
||
| 316 | SessionMessageSendFailed | Engine failed to send message |
|
||
| 317 | SessionProcessMainStarted | Engine process started |
|
||
| 318 | SessionProcessMainShutdown | Engine process shut down |
|
||
| 319 | SessionProcessReceivedStartJob | Engine received task launch request |
|
||
| 320 | SessionProcessReceivedStopJob | Engine received task stop request |
|
||
| 322 | NewInstanceIgnored | Task instance already running |
|
||
| 323 | RunningInstanceStopped | Running instance stopped for new launch |
|
||
| 324 | NewInstanceQueued | Task queued for later launch |
|
||
| 325 | InstanceQueued | Task queued for immediate launch |
|
||
| 326 | NoStartOnBatteries | Computer on batteries, task not started |
|
||
| 327 | StoppingOnBatteries | Instance stopped, switched to battery |
|
||
| 328 | StoppingOffIdle | Instance stopped, computer no longer idle |
|
||
| 329 | StoppingOnTimeout | Instance stopped due to timeout |
|
||
| 330 | StoppingOnRequest | Instance stopped by user request |
|
||
| 331 | TimeoutWontWork | Timeout mechanism creation failed |
|
||
| 332 | NoStartUserNotLoggedOn | User not logged on, task not started |
|
||
| 400 | ScheduleServiceStart | Task Scheduler service started |
|
||
| 401 | ScheduleServiceStartFailed | Service startup failed |
|
||
| 402 | ScheduleServiceStop | Service shutting down |
|
||
| 403 | ScheduleServiceError | Service encountered error |
|
||
| 404 | ScheduleServiceRpcInitError | RPC initialization error |
|
||
| 405 | ScheduleServiceComInitError | COM initialization failed |
|
||
| 406 | ScheduleServiceCredStoreInitError | Credentials store initialization failed |
|
||
| 407 | ScheduleServiceLsaInitError | LSA initialization failed |
|
||
| 408 | ScheduleServiceIdleServiceInitError | Idle detection module initialization failed |
|
||
| 409 | ScheduleServiceTimeChangeInitError | Time change notification initialization failed |
|
||
| 411 | ScheduleServiceTimeChangeSignaled | Service received time change notification |
|
||
| 412 | ScheduleServiceRunBootJobsFailed | Failed to launch boot-triggered tasks |
|
||
| 700 | CompatStart | Compatibility module started |
|
||
| 701 | CompatStartFailed | Compatibility module startup failed |
|
||
| 702 | CompatStartRpcFailed | RPC server initialization failed |
|
||
| 703 | CompatStartNetscheduleFailed | Net Schedule API initialization failed |
|
||
| 704 | CompatStartLsaFailed | LSA initialization failed |
|
||
| 705 | CompatDirectoryMonitorFailed | Directory monitoring startup failed |
|
||
| 706 | CompatTaskStatusUpdateFailed | Task status update failed |
|
||
| 707 | CompatTaskDeleteFailed | Task deletion failed |
|
||
| 708 | CompatTaskSetSdFailed | Security descriptor assignment failed |
|
||
| 709 | CompatTaskUpdateFailed | Task update failed |
|
||
| 710 | CompatUpgradeStartFailed | Upgrade initialization failed |
|
||
| 711 | CompatUpgradeNsAccountFailed | NetSchedule account upgrade failed |
|
||
| 712 | CompatUpgradeStoreEnumFailed | Store enumeration failed |
|
||
| 713 | CompatUpgradeTaskLoadFailed | Task load for upgrade failed |
|
||
| 714 | CompatUpgradeTaskRegistrationFailed | Task registration during upgrade failed |
|
||
| 715 | CompatUpgradeLsaCleanupFailed | LSA store deletion failed |
|
||
| 716 | CompatUpgradeFailed | Task upgrade failed |
|
||
| 717 | CompatUpgradeNeedNotDetermined | Upgrade need determination failed |
|
||
| 718 | VistaBeta2CredstoreUpgradeFailed | Beta 2 credential store upgrade failed |
|
||
| -2 | Unknown | Unknown/undefined value |
|
||
|
||
## [FETCH #30] https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msg
|
||
**ASK:** Give the syntax of msg (username, sessionname, sessionid, @filename, *), the /server, /time, /v, /w options, the remark about needing Message special access permission and any notes about editions or that it works only when a session exists.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: msg | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msg
|
||
breadcrumb_path: /windows-server/breadcrumbs/toc.json
|
||
uhfHeaderId: MSDocsHeader-WindowsServer
|
||
feedback_system: Standard
|
||
recommendations: true
|
||
ms.service: windows-server
|
||
ms.subservice: windows-commands
|
||
ms.update-cycle: 1095-days
|
||
description: Reference article for the msg command, which sends a message to a user on a Remote Desktop Session Host server
|
||
ms.topic: reference
|
||
ms.author: roharwoo
|
||
author: robinharwood
|
||
ms.date: 2022-10-19T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 83436a0e-9eb4-23f5-16ed-1badecb22f48
|
||
document_version_independent_id: 757738ea-6b32-fa58-0d76-12ada0fbd535
|
||
updated_at: 2026-02-16T18:34:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windowsserverdocs-pr/blob/live/WindowsServerDocs/administration/windows-commands/msg.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windowsserverdocs-pr/blob/48fd05321fd0fe328b1977597b554d884ca5e35d/WindowsServerDocs/administration/windows-commands/msg.md
|
||
git_commit_id: 48fd05321fd0fe328b1977597b554d884ca5e35d
|
||
site_name: Docs
|
||
depot_name: MSDN.WindowsServerDocs-pr
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.WindowsServerDocs-pr/{branchName}{pdfName}
|
||
feedback_product_url: ''
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 452
|
||
asset_id: administration/windows-commands/msg
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: WindowsServerDocs/administration/windows-commands/msg.md
|
||
cmProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/ddab3cd8-636f-4a91-896e-1c23f399a6bd
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/fc3f72c2-fb6f-4cea-95ee-b444e52254ee
|
||
spProducts:
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/f409bb5d-e203-40c5-9d95-0ee717231beb
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/f12cf087-582d-48ac-a085-0c19adf1e391
|
||
platformId: 04e2a1d4-70a5-6145-387a-a93a8fbfe63e
|
||
---
|
||
|
||
# msg | Microsoft Learn
|
||
|
||
Sends a message to a user on a Remote Desktop Session Host server.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
You must have Message special access permission to send a message.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
```
|
||
|
||
msg {<username> | <sessionname> | <sessionID>| @<filename> | *} [/server:<servername>] [/time:<seconds>] [/v] [/w] [<message>]
|
||
|
||
```
|
||
|
||
|
||
|
||
### Parameters
|
||
|
||
|
||
|
||
| Parameter | Description |
|
||
|
||
| --- | --- |
|
||
|
||
| `<username>` | Specifies the name of the user that you want to receive the message. If you don't specify a user or a session, this command displays an error message. When specifying a session, it must be an active one. |
|
||
|
||
| `<sessionname>` | Specifies the name of the session that you want to receive the message. If you don't specify a user or a session, this command displays an error message. When specifying a session, it must be an active one. |
|
||
|
||
| `<sessionID>` | Specifies the numeric ID of the session whose user you want to receive a message. |
|
||
|
||
| `@<filename>` | Identifies a file containing a list of user names, session names, and session IDs that you want to receive the message. |
|
||
|
||
| \* | Sends the message to all user names on the system. |
|
||
|
||
| /server:`<servername>` | Specifies the Remote Desktop Session Host server whose session or user you want to receive the message. If unspecified, **/server** uses the server to which you are currently logged on. |
|
||
|
||
| /time:`<seconds>` | Specifies the amount of time that the message you sent is displayed on the user's screen. After the time limit is reached, the message disappears. If no time limit is set, the message defaults to **60 seconds** and disappears. |
|
||
|
||
| /v | Displays information about the actions being performed. |
|
||
|
||
| /w | Waits for an acknowledgment from the user that the message has been received. Use this parameter with `/time:<*seconds*>` to avoid a possible long delay if the user does not immediately respond. Using this parameter with **/v** is also helpful. |
|
||
|
||
| `<message>` | Specifies the text of the message that you want to send. If no message is specified, you will be prompted to enter a message. To send a message that is contained in a file, type the less than (<) symbol followed by the file name. |
|
||
|
||
| /? | Displays help at the command prompt. |
|
||
|
||
|
||
|
||
### Examples
|
||
|
||
|
||
|
||
To send a message entitled, *Let's meet at 1PM today* to all sessions for *User1*, type:
|
||
|
||
|
||
|
||
```
|
||
|
||
msg User1 Let's meet at 1PM today
|
||
|
||
```
|
||
|
||
|
||
|
||
To send the same message to session *modeM02*, type:
|
||
|
||
|
||
|
||
```
|
||
|
||
msg modem02 Let's meet at 1PM today
|
||
|
||
```
|
||
|
||
|
||
|
||
To send the message to all sessions contained in the file *userlist*, type:
|
||
|
||
|
||
|
||
```
|
||
|
||
msg @userlist Let's meet at 1PM today
|
||
|
||
```
|
||
|
||
|
||
|
||
To send the message to all users who are logged on, type:
|
||
|
||
|
||
|
||
```
|
||
|
||
msg * Let's meet at 1PM today
|
||
|
||
```
|
||
|
||
|
||
|
||
To send the message to all users, with an acknowledgment time-out (for example, 10 seconds), type:
|
||
|
||
|
||
|
||
```
|
||
|
||
msg * /time:10 Let's meet at 1PM today
|
||
|
||
```
|
||
|
||
|
||
|
||
## Related links
|
||
|
||
|
||
|
||
- [Command-Line Syntax Key](command-line-syntax-key)
|
||
|
||
## [FETCH #31] https://github.com/winsw/winsw/blob/v3/docs/xml-config-file.md
|
||
**ASK:** Extract the XML elements: executable, arguments, workingdirectory, env, log (mode roll-by-size / roll-by-time, sizeThreshold, keepFiles), onfailure (action restart/reboot/none, delay), resetfailure, startmode, delayedAutoStart, stoptimeout, serviceaccount (username/password/allowservicelogon), interactive flag and any warning about it. Give an example XML with onfailure and log rolling.
|
||
|
||
# WinSW XML Configuration Elements
|
||
|
||
## Key Elements
|
||
|
||
**executable** (Required): Specifies the program to launch, either as an absolute path or searchable name from PATH.
|
||
|
||
**arguments**: "The `<arguments>` element specifies the arguments to be passed to the executable."
|
||
|
||
**workingdirectory**: Sets the service's working directory. "Some services need to run with a working directory specified."
|
||
|
||
**env**: Environment variables for child processes using syntax: `<env name="HOME" value="c:\abc" />`
|
||
|
||
**log**: Configures logging with modes including roll. Supports `<logpath>` and startup modes: append (default), reset, ignore, or roll.
|
||
|
||
**onfailure**: Controls behavior on process failure with `action` (restart/reboot/none) and optional `delay` attributes.
|
||
|
||
**resetfailure**: "Controls the timing in which Windows SCM resets the failure count." Defaults to 1 day.
|
||
|
||
**startmode**: Sets service startup to Automatic or Manual. Default is Automatic.
|
||
|
||
**delayedAutoStart**: Boolean enabling delayed start with Automatic mode. "Will not take affect on old Windows versions older than Windows 7."
|
||
|
||
**stoptimeout**: Allows customization of graceful shutdown duration (default 15 seconds).
|
||
|
||
**serviceaccount**: Specifies service identity with `<username>`, `<password>`, and optional `<allowservicelogon>`.
|
||
|
||
**interactive**: "If specified, the service will be allowed to interact with the desktop." ⚠️ **Warning**: Since Windows Vista/UAC, services cannot truly interact with the desktop.
|
||
|
||
## Example XML with onfailure and log rolling
|
||
|
||
```xml
|
||
<service>
|
||
<id>myservice</id>
|
||
<executable>java</executable>
|
||
<arguments>-jar myapp.jar</arguments>
|
||
<workingdirectory>C:\app</workingdirectory>
|
||
<env name="JAVA_HOME" value="C:\Java"/>
|
||
<log mode="roll"/>
|
||
<onfailure action="restart" delay="10 sec"/>
|
||
<onfailure action="restart" delay="20 sec"/>
|
||
<onfailure action="reboot"/>
|
||
<resetfailure>1 hour</resetfailure>
|
||
<stoptimeout>10sec</stoptimeout>
|
||
<startmode>Automatic</startmode>
|
||
</service>
|
||
```
|
||
|
||
## [FETCH #32] https://code.claude.com/docs/en/headless
|
||
**ASK:** Summarize the official Claude Code headless / print mode docs: the -p/--print flag, --output-format (text/json/stream-json), --allowedTools / --permission-mode / --dangerously-skip-permissions, --max-turns, exit codes, how to pipe stdin, and any note about running in CI/cron. Quote exact flag names only as they appear.
|
||
|
||
> ## Documentation Index
|
||
> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt
|
||
> Use this file to discover all available pages before exploring further.
|
||
|
||
# Run Claude Code programmatically
|
||
|
||
> Use the Agent SDK to run Claude Code programmatically from the CLI, Python, or TypeScript.
|
||
|
||
The [Agent SDK](/docs/en/agent-sdk/overview) gives you the same tools, agent loop, and context management that power Claude Code. It's available as a CLI for scripts and CI/CD, or as [Python](/docs/en/agent-sdk/python) and [TypeScript](/docs/en/agent-sdk/typescript) packages for full programmatic control.
|
||
|
||
To run Claude Code in non-interactive mode, pass `-p` with your prompt and the [CLI options](/docs/en/cli-reference) you need:
|
||
|
||
```bash theme={null}
|
||
claude -p "Find and fix the bug in auth.py" --allowedTools "Read,Edit,Bash"
|
||
```
|
||
|
||
This page covers using the Agent SDK via the CLI (`claude -p`). For the Python and TypeScript SDK packages with structured outputs, tool approval callbacks, and native message objects, see the [full Agent SDK documentation](/docs/en/agent-sdk/overview).
|
||
|
||
## Basic usage
|
||
|
||
Add the `-p` (or `--print`) flag to any `claude` command to run it non-interactively. Not every [CLI option](/docs/en/cli-reference) combines with `-p`. Claude Code rejects `--bg`, and rejects `--cloud` with a task description, with an error naming the conflict; `--cloud` with a session ID and `-p` instead [queues a message into that cloud session](/docs/en/claude-code-on-the-web#send-follow-ups-from-the-cli) and exits. Options you'll combine with `-p` often include:
|
||
|
||
* `--continue` for [continuing conversations](#continue-conversations)
|
||
* `--allowedTools` for [auto-approving tools](#auto-approve-tools)
|
||
* `--output-format` for [structured output](#get-structured-output)
|
||
|
||
This example asks Claude a question about your codebase and prints the response:
|
||
|
||
```bash theme={null}
|
||
claude -p "What does the auth module do?"
|
||
```
|
||
|
||
Claude Code exits with code 0 on success and a non-zero code when the run fails, so your scripts can branch on the exit status. If you pass an invalid flag, Claude Code reports the error to stderr before the run starts. When a failure happens inside the run, such as missing authentication, Claude Code prints the failure as the result on stdout.
|
||
|
||
### Start faster with bare mode
|
||
|
||
Add `--bare` to reduce startup time by skipping auto-discovery of hooks, skills, custom commands, [subagents](/docs/en/sub-agents), plugins, MCP servers, auto memory, and CLAUDE.md. Without it, `claude -p` loads the same [context](/docs/en/how-claude-code-works#the-context-window) an interactive session would, including anything configured in the working directory or `~/.claude`.
|
||
|
||
Bare mode is useful for CI and scripts where you need the same result on every machine. A hook in a teammate's `~/.claude` or an MCP server in the project's `.mcp.json` won't run, because bare mode never reads them. A directory you name with `--add-dir` is a partial exception: bare mode loads skills from its `.claude/skills/` folder, but still skips its `.claude/commands/` and `.claude/agents/` folders. [Skills from additional directories](/docs/en/skills#skills-from-additional-directories) covers what does and doesn't load.
|
||
|
||
Without `--bare`, a `-p` session runs the hooks in a project's `.claude/settings.json` and connects the servers in its `.mcp.json`, even in a folder you've never trusted. A `-p` session shows no workspace trust dialog and no per-server approval prompt. [What runs before you trust a folder](/docs/en/permissions#what-runs-before-you-trust-a-folder) covers each kind of repository content under `-p` and how to keep it out.
|
||
|
||
This example runs a one-off summarize task in bare mode and pre-approves the Read tool so the call completes without a permission prompt. Set `ANTHROPIC_API_KEY` before running it, because bare mode doesn't use your subscription login:
|
||
|
||
```bash theme={null}
|
||
claude --bare -p "Summarize README.md" --allowedTools "Read"
|
||
```
|
||
|
||
In bare mode, Claude Code never reads OAuth credentials or the system keychain. For the Anthropic API, set `ANTHROPIC_API_KEY` in the environment, with a key created in the [Claude Console](https://platform.claude.com), or supply an `apiKeyHelper` in the `--settings` JSON. Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry continue to read their own provider credentials as usual.
|
||
|
||
In bare mode Claude has access to the Bash, file read, and file edit tools. Pass any context you need with a flag:
|
||
|
||
| To load | Use |
|
||
| ----------------------- | ------------------------------------------------------- |
|
||
| System prompt additions | `--append-system-prompt`, `--append-system-prompt-file` |
|
||
| Settings | `--settings <file-or-json>` |
|
||
| MCP servers | `--mcp-config <file-or-json>` |
|
||
| Custom agents | `--agents <json>` |
|
||
| A plugin | `--plugin-dir <path>`, `--plugin-url <url>` |
|
||
|
||
<Note>
|
||
`--bare` is the recommended mode for scripted and SDK calls, and will become the default for `-p` in a future release.
|
||
</Note>
|
||
|
||
### Background tasks at exit
|
||
|
||
If Claude starts a [background Bash task](/docs/en/tools-reference#bash-tool-behavior) during a `claude -p` run, for example a dev server or a watch build, that shell is terminated about five seconds after Claude has returned its final result and stdin has closed. The grace period lets a task that finishes right after the result still deliver its output. Before v2.1.163, a never-exiting background process would hold the `claude -p` invocation open indefinitely.
|
||
|
||
Background [subagents](/docs/en/sub-agents) and workflows are exempt from the five-second grace because their result is part of the final output, so `claude -p` waits for them to complete. From v2.1.182, that wait is capped at ten minutes of continuous idle waiting by default, so a stuck background agent can't hold the process open indefinitely. Adjust the cap with [`CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS`](/docs/en/env-vars), or set it to `0` to wait without a limit.
|
||
|
||
### Stop a run with SIGTERM
|
||
|
||
If you stop a `claude -p` run with SIGTERM, for example with `kill` or from a process supervisor, Claude Code exits with code 143. Claude Code leaves the turn that was in progress unfinished and records no result for it. To end the turn instead, send SIGINT, or call the Agent SDK's `interrupt()`, before you stop the process.
|
||
|
||
On SIGTERM, Claude Code terminates the process tree of any Bash command that is still running. Claude Code then runs [`SessionEnd` hooks](/docs/en/hooks#sessionend) and exits. While exiting, Claude Code starts no new tool call, sends no new model request, and runs no hook other than `SessionEnd`. If the run was in the middle of a command or waiting on a permission prompt when the signal arrived, Claude Code handles that step as follows:
|
||
|
||
* **Running a command**: Claude Code records the command as killed in the session.
|
||
* **Waiting for an answer to a permission prompt**: if you send SIGTERM to the process, Claude Code leaves the prompt unanswered. If your program closes the session through the Agent SDK, the SDK ends Claude Code's input before sending any signal, and Claude Code cancels the prompt as soon as the input ends.
|
||
|
||
When you [resume the session](#continue-conversations), Claude Code continues the turn that SIGTERM left unfinished.
|
||
|
||
## Examples
|
||
|
||
These examples highlight common CLI patterns. Where a command names a file such as `auth.py` or `build-error.txt`, substitute a file from your own project. In CI or other scripted environments, add [`--bare`](#start-faster-with-bare-mode) so Claude Code starts without loading the host's hooks, plugins, auto memory, or `CLAUDE.md`.
|
||
|
||
### Pipe data through Claude
|
||
|
||
Non-interactive mode reads stdin, so you can pipe data in and redirect the response out like any other command-line tool.
|
||
|
||
This example pipes a build log into Claude and writes the explanation to a file:
|
||
|
||
```bash theme={null}
|
||
cat build-error.txt | claude -p 'concisely explain the root cause of this build error' > output.txt
|
||
```
|
||
|
||
With `--output-format json`, the response payload includes `total_cost_usd` and a per-model cost breakdown, so scripted callers can track spend per invocation without consulting the [usage dashboard](/docs/en/costs). Both figures are [client-side estimates](/docs/en/agent-sdk/cost-tracking) and can differ from your actual bill.
|
||
|
||
<Note>
|
||
Piped stdin is capped at 10MB. If you exceed the cap, Claude Code exits with a clear error and a non-zero status. To work with larger inputs, write the content to a file and reference the file path in your prompt instead of piping it.
|
||
</Note>
|
||
|
||
If Claude Code can't read stdin, for example because the process that started it disconnected its end, Claude Code prints a warning to stderr and continues with the prompt from the command line. Before v2.1.211, an unreadable stdin on Windows crashed the session or made it exit silently with no output.
|
||
|
||
### Add Claude to a build script
|
||
|
||
You can wrap a non-interactive call in a script to use Claude as a project-specific linter or reviewer.
|
||
|
||
This `package.json` script pipes the diff against `main` into Claude and asks it to report typos. Piping the diff means Claude doesn't need Bash permission to read it, and the escaped double quotes keep the script portable to Windows:
|
||
|
||
```json theme={null}
|
||
{
|
||
"scripts": {
|
||
"lint:claude": "git diff main | claude -p \"you are a typo linter. for each typo in this diff, report filename:line on one line and the issue on the next. return nothing else.\""
|
||
}
|
||
}
|
||
```
|
||
|
||
Run it with `npm run lint:claude`.
|
||
|
||
### Get structured output
|
||
|
||
Use `--output-format` to control how responses are returned:
|
||
|
||
* `text` (default): plain text output
|
||
* `json`: structured JSON with result, session ID, and metadata
|
||
* `stream-json`: newline-delimited JSON for real-time streaming
|
||
|
||
This example returns a project summary as JSON with session metadata, with the text result in the `result` field:
|
||
|
||
```bash theme={null}
|
||
claude -p "Summarize this project" --output-format json
|
||
```
|
||
|
||
To get output conforming to a specific schema, use `--output-format json` with `--json-schema` and a [JSON Schema](https://json-schema.org/) definition. The response includes metadata about the request (session ID, usage, etc.) with the structured output in the `structured_output` field.
|
||
|
||
This example extracts function names and returns them as an array of strings:
|
||
|
||
```bash theme={null}
|
||
claude -p "Extract the main function names from auth.py" \
|
||
--output-format json \
|
||
--json-schema '{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}},"required":["functions"]}'
|
||
```
|
||
|
||
If the value isn't a valid JSON Schema, `claude` exits with `Error: --json-schema is not a valid JSON Schema` followed by the validator's diagnostic. Claude Code accepts schemas that use the `format` keyword, such as `"format": "email"`, but treats `format` as an annotation and doesn't enforce it. Before v2.1.205, Claude Code silently ignored an invalid schema and returned unstructured text, and treated any schema containing `format` as invalid.
|
||
|
||
<Tip>
|
||
Use a tool like [jq](https://jqlang.org/) to parse the response and extract specific fields:
|
||
|
||
```bash theme={null}
|
||
# Extract the text result
|
||
claude -p "Summarize this project" --output-format json | jq -r '.result'
|
||
|
||
# Extract structured output
|
||
claude -p "Extract function names from auth.py" \
|
||
--output-format json \
|
||
--json-schema '{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}},"required":["functions"]}' \
|
||
| jq '.structured_output'
|
||
```
|
||
</Tip>
|
||
|
||
### Stream responses
|
||
|
||
Use `--output-format stream-json` with `--verbose` and `--include-partial-messages` to receive tokens as they're generated. Each line is a JSON object representing an event:
|
||
|
||
```bash theme={null}
|
||
claude -p "Explain recursion" --output-format stream-json --verbose --include-partial-messages
|
||
```
|
||
|
||
The last line of the stream is a `result` message with the final response text, cost, and session metadata.
|
||
|
||
If your consumer reads the stream slowly, Claude Code waits for the queued output to drain before exiting, scaling the wait with how much is still queued, capped at 30 seconds. Before v2.1.214 the exit wait was capped at about two seconds, which could cut off the end of a large response.
|
||
|
||
The following example uses [jq](https://jqlang.org/) to filter for text deltas and display just the streaming text. The `-r` flag outputs raw strings (no quotes) and `-j` joins without newlines so tokens stream continuously:
|
||
|
||
```bash theme={null}
|
||
claude -p "Write a poem" --output-format stream-json --verbose --include-partial-messages | \
|
||
jq -rj 'select(.type == "stream_event" and .event.delta.type? == "text_delta") | .event.delta.text'
|
||
```
|
||
|
||
For programmatic streaming with callbacks and message objects, see [Stream responses in real-time](/docs/en/agent-sdk/streaming-output) in the Agent SDK documentation.
|
||
|
||
#### Follow subagent messages
|
||
|
||
Messages from [subagents](/docs/en/sub-agents) appear in the stream as `assistant` and `user` messages whose `parent_tool_use_id` field is the ID of the tool call that spawned the subagent. Messages from the main conversation carry `null` in that field.
|
||
|
||
By default, Claude Code emits only subagent `tool_use` and `tool_result` blocks. Pass [`--forward-subagent-text`](/docs/en/cli-reference#cli-flags) or set [`CLAUDE_CODE_FORWARD_SUBAGENT_TEXT`](/docs/en/env-vars) to also emit subagent text and thinking blocks, so you can reconstruct each subagent's transcript. This requires Claude Code v2.1.211 or later.
|
||
|
||
When you enable either option, Claude Code forwards messages from [subagents at every nesting depth](/docs/en/sub-agents#let-subagents-spawn-their-own-subagents): when a subagent spawns its own subagent, the nested s
|
||
…[truncated 16635 chars]
|
||
|
||
## [FETCH #33] https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-eventlog?view=powershell-5.1
|
||
**ASK:** Give the syntax of New-EventLog (-LogName, -Source, -ComputerName), the note that it requires administrator rights and that it is Windows PowerShell 5.1 only, plus an example. Also note whether there is a message about it not being in PowerShell 7.
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- powershell-5.1
|
||
defaultMoniker: powershell-5.1
|
||
versioningType: Ranged
|
||
title: New-EventLog (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-eventlog?view=powershell-5.1
|
||
config_moniker_range: powershell-5.1
|
||
uid: Microsoft.PowerShell.Management.New-EventLog
|
||
module: Microsoft.PowerShell.Management
|
||
description: 'This cmdlet creates a new classic event log on a local or remote computer. It can also register an event source that writes to the new log or to an existing log. The cmdlets that contain the EventLog noun (the Event log cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use Get-WinEvent. '
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/scripting/overview
|
||
breadcrumb_path: /powershell/scripting/bread/toc.json
|
||
feedback_product_url: https://github.com/PowerShell/PowerShell/issues/new/choose
|
||
feedback_help_link_url: https://learn.microsoft.com/powershell/scripting/community/community-support
|
||
feedback_help_link_type: ask-the-community
|
||
feedback_system: OpenSource
|
||
hideScope: false
|
||
author: sdwheeler
|
||
ms.author: sewhee
|
||
manager: jasongroce
|
||
ms.devlang: powershell
|
||
ms.service: powershell
|
||
ms.tgt_pltfr: windows, macos, linux
|
||
ms.update-cycle: 365-days
|
||
toc_preview: true
|
||
uhfHeaderId: MSDocsHeader-Powershell
|
||
ms.topic: reference
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/8bce367e-2e90-4b56-9ed5-5e4e9f3a2dc3
|
||
document type: cmdlet
|
||
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/new-eventlog?view=powershell-5.1&WT.mc_id=ps-gethelp
|
||
Locale: en-us
|
||
Module Name: Microsoft.PowerShell.Management
|
||
ms.date: 2022-05-17T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
document_id: 6dfed927-ad93-1ee4-9c23-2d53ab07a180
|
||
document_version_independent_id: b63cdcb8-0581-8479-ecc8-ee19e8973692
|
||
updated_at: 2025-03-24T22:01:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/live/reference/5.1/Microsoft.PowerShell.Management/New-EventLog.md
|
||
gitcommit: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/a178933206c5076d3658c54713cae3680ed1a893/reference/5.1/Microsoft.PowerShell.Management/New-EventLog.md
|
||
git_commit_id: a178933206c5076d3658c54713cae3680ed1a893
|
||
default_moniker: powershell-5.1
|
||
site_name: Docs
|
||
depot_name: PowerShell.PowerShell_PowerShell-docs_reference
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../psdocs/toc.json
|
||
asset_id: module/microsoft.powershell.management/new-eventlog
|
||
moniker_range_name: 5c70fd29722c65e9f104798d23172c2d
|
||
monikers:
|
||
- powershell-5.1
|
||
item_type: Content
|
||
source_path: reference/5.1/Microsoft.PowerShell.Management/New-EventLog.md
|
||
cmProducts: []
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: c4038aca-34cb-0ff8-3a61-cf76a6b1b675
|
||
---
|
||
|
||
# New-EventLog
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [Microsoft.PowerShell.Management Module](./)
|
||
|
||
|
||
|
||
Creates a new event log and a new event source on a local or remote computer.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### Default (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
New-EventLog
|
||
|
||
[-LogName] <string>
|
||
|
||
[-Source] <string[]>
|
||
|
||
[[-ComputerName] <string[]>]
|
||
|
||
[-CategoryResourceFile <string>]
|
||
|
||
[-MessageResourceFile <string>]
|
||
|
||
[-ParameterResourceFile <string>]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
This cmdlet creates a new classic event log on a local or remote computer. It can also register an event source that writes to the new log or to an existing log.
|
||
|
||
|
||
|
||
The cmdlets that contain the `EventLog` noun (the Event log cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use `Get-WinEvent`.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1 - create a new event log
|
||
|
||
|
||
|
||
This command creates the `TestLog` event log on the local computer and registers a new source for it.
|
||
|
||
|
||
|
||
```powershell
|
||
|
||
New-EventLog -Source TestApp -LogName TestLog -MessageResourceFile C:\Test\TestApp.dll
|
||
|
||
```
|
||
|
||
|
||
|
||
### Example 2 - add a new event source to an existing log
|
||
|
||
|
||
|
||
This command adds a new event source, `NewTestApp`, to the Application log on the Server01 remote computer.
|
||
|
||
|
||
|
||
```powershell
|
||
|
||
$file = "C:\Program Files\TestApps\NewTestApp.dll"
|
||
|
||
New-EventLog -ComputerName Server01 -Source NewTestApp -LogName Application -MessageResourceFile $file -CategoryResourceFile $file
|
||
|
||
```
|
||
|
||
|
||
|
||
The command requires that the `NewTestApp.dll` file is located on the Server01 computer.
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -CategoryResourceFile
|
||
|
||
|
||
|
||
Specifies the path to the file that contains category strings for the source events. This file is also known as the Category Message File.
|
||
|
||
|
||
|
||
The file must be present on the computer on which the event log is being created. This parameter does not create or move files.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | CRF |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ComputerName
|
||
|
||
|
||
|
||
Creates the new event logs on the specified computers. The default is the local computer.
|
||
|
||
|
||
|
||
The NetBIOS name, IP address, or fully qualified domain name of a remote computer. To specify the local computer, type the computer name, a dot (`.`), or `localhost`.
|
||
|
||
|
||
|
||
This parameter does not rely on PowerShell remoting. You can use the **ComputerName** parameter of `Get-EventLog` even if your computer is not configured to run remote commands.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string)[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | Local computer |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | CN |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 3 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -LogName
|
||
|
||
|
||
|
||
Specifies the name of the event log.
|
||
|
||
|
||
|
||
If the log does not exist, `New-EventLog` creates the log and uses this value for the **Log** and **LogDisplayName** properties of the new event log. If the log exists, `New-EventLog` registers a new source for the event log.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | LN |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 1 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -MessageResourceFile
|
||
|
||
|
||
|
||
Specifies the path to the file that contains message formatting strings for the source events. This file is also known as the Event Message File.
|
||
|
||
|
||
|
||
The file must be present on the computer on which the event log is being created. This parameter does not create or move files.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | MRF |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ParameterResourceFile
|
||
|
||
|
||
|
||
Specifies the path to the file that contains strings used for parameter substitutions in event descriptions. This file is also known as the Parameter Message File.
|
||
|
||
|
||
|
||
The file must be present on the computer on which the event log is being created. This parameter does not create or move files.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | PRF |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Source
|
||
|
||
|
||
|
||
Specifies the names of the event log sources, such as application programs that write to the event log. This parameter is required.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string)[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | SRC |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### CommonParameters
|
||
|
||
|
||
|
||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
|
||
|
||
|
||
|
||
## Inputs
|
||
|
||
|
||
|
||
### None
|
||
|
||
|
||
|
||
You cannot pipe input to this cmdlet.
|
||
|
||
|
||
|
||
## Outputs
|
||
|
||
|
||
|
||
### [EventLogEntry](/en-us/dotnet/api/system.diagnostics.eventlogentry)
|
||
|
||
|
||
|
||
## Notes
|
||
|
||
|
||
|
||
To use `New-EventLog` on Windows Vista and later versions of Windows, open PowerShell with the **Run as administrator** option.
|
||
|
||
|
||
|
||
To create an event source in Windows Vista, Windows XP Professional, or Windows Server 2003, you must be a member of the Administrators group on the computer.
|
||
|
||
|
||
|
||
When you create a new event log and a new event source, the system registers the new source for the new log, but the log is not created until the first entry is written to it.
|
||
|
||
|
||
|
||
The operating system stores event logs as files.
|
||
|
||
|
||
|
||
When you create a new event log, the associated file is stored in the `$Env:SystemRoot\System32\Config` directory on the specified computer.
|
||
|
||
|
||
|
||
The file name is the first eight characters of the **Log** property with an `.evt` file name extension.
|
||
|
||
|
||
|
||
## Related Links
|
||
|
||
|
||
|
||
- [Clear-EventLog](clear-eventlog)
|
||
|
||
- [Get-EventLog](get-eventlog)
|
||
|
||
- [Get-WinEvent](../microsoft.powershell.diagnostics/get-winevent)
|
||
|
||
- [Limit-EventLog](limit-eventlog)
|
||
|
||
- [New-EventLog](new-eventlog)
|
||
|
||
- [Remove-EventLog](remove-eventlog)
|
||
|
||
- [Show-EventLog](show-eventlog)
|
||
|
||
- [Write-EventLog](write-eventlog)
|
||
|
||
## [FETCH #34] https://learn.microsoft.com/en-us/answers/a/1082877
|
||
**ASK:** Summarize the question and answer: why a scheduled task sits queued until someone logs in, what logon type/setting causes it (Run only when user is logged on / interactive token), and the fix (Run whether user is logged on or not with stored password, or S4U).
|
||
|
||
# Scheduled Task Queued Until First Login - Summary
|
||
|
||
## The Problem
|
||
|
||
The user's PowerShell script creates a scheduled task to install Avid Pro Tools on newly deployed computers. The task works immediately when created on a computer where someone has already logged in, but on fresh deployments with no prior user login, the task sits in a **"Queued"** state until someone manually logs in for the first time.
|
||
|
||
## Root Cause
|
||
|
||
The issue relates to the **logon type/session configuration** of the scheduled task:
|
||
|
||
- **"Run only when user is logged on"** (Interactive token) - The task requires an active user session and will queue until someone logs in
|
||
- The task is set to run as a specific user (`tempadmin`), but without the proper configuration for running without an interactive session
|
||
|
||
## The Fix
|
||
|
||
According to the discussion, there are two solutions:
|
||
|
||
### Solution 1: Use "Run whether user is logged on or not"
|
||
Modify the task registration to include the `-RunLevel` parameter and store credentials:
|
||
|
||
```powershell
|
||
Register-ScheduledTask -TaskName $taskname `
|
||
-User $User `
|
||
-Password $password `
|
||
-Action $action `
|
||
-RunLevel Highest
|
||
```
|
||
|
||
This requires storing the password (which the script already does) and configures the task to run in a non-interactive context.
|
||
|
||
### Solution 2: Use S4U (Service-for-User)
|
||
Alternatively, configure the scheduled task to use S4U (Kerberos Service-for-User) delegation, which allows the task to impersonate the user without requiring an interactive logon.
|
||
|
||
## Key Insight
|
||
|
||
The task's behavior changes based on whether **at least one interactive logon has occurred on the system**. Once a user logs in, certain system services and user profile initialization occurs that allows queued tasks to execute. Running the task before any interactive logon fails because these prerequisites haven't been initialized.
|
||
|
||
## [FETCH #35] https://blog.programster.org/uptime-kuma-configure-push-monitor
|
||
**ASK:** Extract the push URL format (https://host/api/push/TOKEN?status=up&msg=OK&ping=), the heartbeat interval / retries settings, and the example command used to ping (curl/wget).
|
||
|
||
# Uptime Kuma Push Monitor Configuration
|
||
|
||
## Push URL Format
|
||
The article references a URL structure for push monitoring but doesn't explicitly state the full format you mentioned. It indicates copying "this URL for your code" during setup, though the exact endpoint pattern isn't detailed in the visible content.
|
||
|
||
## Heartbeat & Retry Settings
|
||
According to the tutorial: "Set a heartbeat interval. If your service does not 'check in' within this time period of its last 'check in', then Uptime Kuma will assume the service is down." The minimum interval is 20 seconds. The author also recommends configuring "the number of retry a limit and the retry interval" to provide "a 'grace period' for if your service missed a 'check in' or two."
|
||
|
||
## Example Ping Commands
|
||
The article provides these code examples:
|
||
|
||
**Python:**
|
||
```python
|
||
import requests
|
||
r = requests.get("http://uptimekuma.mydomain.com/api/push/xyz")
|
||
```
|
||
|
||
**PHP:** The tutorial mentions `file_get_contents()` as a basic approach or `curl_multi_exec()` for asynchronous requests to avoid blocking operations.
|
||
|
||
The content doesn't include explicit curl or wget command examples—only programmatic implementations.
|
||
|
||
## [FETCH #36] https://learn.microsoft.com/en-us/windows/deployment/update/waas-restart
|
||
**ASK:** Summarize: how active hours work (max range 18 hours), how to set them via Settings/Group Policy/registry (HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate ActiveHoursStart/ActiveHoursEnd, SetActiveHours), 'Schedule the restart' options, and 'No auto-restart with logged on users for scheduled automatic updates installations' policy. Give registry value names exactly.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Manage device restarts after updates | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/deployment/update/waas-restart
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.collection:
|
||
- highpri
|
||
- tier2
|
||
breadcrumb_path: /windows/resources/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-Windows
|
||
feedback_system: Standard
|
||
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
|
||
description: Use group policy settings, mobile device management (MDM), or registry to configure when devices will restart after a Windows update is installed.
|
||
ms.service: windows-client
|
||
ms.subservice: itpro-updates
|
||
ms.topic: how-to
|
||
author: officedocspr5
|
||
ms.author: odocspr
|
||
manager: bpardi
|
||
ms.localizationpriority: medium
|
||
ms.date: 2025-09-26T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: 0184809a-63ff-ecc2-ab67-9c9f4df900f8
|
||
document_version_independent_id: ac25ee6c-4c57-58b3-1313-e4a53f53c5a1
|
||
updated_at: 2025-10-02T15:02:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-docs-pr/blob/live/windows/deployment/update/waas-restart.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-docs-pr/blob/8c73a53d222e95ab480d2e88bd8124ac3e3dba97/windows/deployment/update/waas-restart.md
|
||
git_commit_id: 8c73a53d222e95ab480d2e88bd8124ac3e3dba97
|
||
site_name: Docs
|
||
depot_name: TechNet.win-deployment
|
||
page_type: conceptual
|
||
toc_rel: ../toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/TechNet.win-deployment/{branchName}{pdfName}
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 2881
|
||
asset_id: update/waas-restart
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: windows/deployment/update/waas-restart.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/19ec6774-09b8-473e-a17e-b17b518bbad7
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://microsoft-devrel.poolparty.biz/DevRelOfferingOntology/ade36b61-c646-4bd8-87ee-f3a843461962
|
||
platformId: 54282049-f8e0-c0e3-9c10-f92c51825ef2
|
||
---
|
||
|
||
# Manage device restarts after updates | Microsoft Learn
|
||
|
||
>
|
||
|
||
> **Looking for consumer information?** See [Windows Update: FAQ](https://support.microsoft.com/windows/windows-update-faq-8a903416-6f45-0718-f5c7-375e92dddeb2)
|
||
|
||
|
||
|
||
You can use group policy settings, mobile device management (MDM), or the Windows registry to configure when devices will restart after a Windows update is installed. You can schedule update installation and set policies for restart, configure active hours for when restarts shouldn't occur, or you can do both.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
Directly editing the Windows registry isn't recommended.
|
||
|
||
|
||
|
||
## Schedule update installation
|
||
|
||
|
||
|
||
In group policy, within **Configure Automatic Updates**, you can configure a forced restart after a specified installation time.
|
||
|
||
|
||
|
||
To set the time, go to **Configure Automatic Updates**, select option **4 - Auto download and schedule the install**, and then use **Scheduled install time** to enter a time. Alternatively, you can specify that installation occurs during the automatic maintenance time. To configure this alternative method, use **Computer Configuration\Administrative Templates\Windows Components\Maintenance Scheduler**.
|
||
|
||
|
||
|
||
The setting to **Always automatically restart at the scheduled time** forces a restart after the specified installation time. It lets you configure a timer to warn a signed-in user that a restart is going to occur. This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
|
||
|
||
While not recommended, you can achieve the same result with the Windows registry. Under `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU`, set `AuOptions` to `4` and set the install time with `ScheduledInstallTime`. Enable `AlwaysAutoRebootAtScheduledTime` and specify the delay in minutes through `AlwaysAutoRebootAtScheduledTimeMinutes`. Similar to group policy, `AlwaysAutoRebootAtScheduledTimeMinutes` sets the timer to warn a signed-in user that a restart is going to occur.
|
||
|
||
|
||
|
||
For a detailed description of these registry keys, see Registry keys used to manage restart.
|
||
|
||
|
||
|
||
## Delay automatic restart
|
||
|
||
|
||
|
||
When you enable **Configure Automatic Updates** in group policy, you can also enable one of the following policies to delay an automatic restart after update installation:
|
||
|
||
|
||
|
||
- **Turn off auto-restart for updates during active hours** prevents automatic restart during active hours.
|
||
|
||
- **No auto-restart with logged on users for scheduled automatic updates installations** prevents automatic restart when a user is signed in. If a user schedules the restart in the update notification, the device restarts at the time the user specifies even if a user is signed in at the time. This policy only applies when **Configure Automatic Updates** is set to option **4 - Auto download and schedule the install**.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
- When using Remote Desktop Protocol (RDP) connections, only active RDP sessions are considered signed-in users. Devices that don't have locally signed-in users, or active RDP sessions, are restarted.
|
||
|
||
- The **No auto-restart with logged on users for scheduled automatic updates installation** policy was never created as a CSP. In Group Policy this policy doesn't work exactly as per description. This policy can result in no quality update reboots period, given many users never log off. The recommendation to replace this would be to leverage compliance deadline and then to configure no-auto reboot to prevent non-user aware reboots prior to the deadline being reached. For server devices, leverage Configure Automatic Updates options 7 - notify to install and notify to reboot.
|
||
|
||
|
||
|
||
You can also use the Windows registry, to prevent automatic restarts when a user is signed in. Under `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU`, set `AuOptions` to `4` and enable `NoAutoRebootWithLoggedOnUsers`. As with group policy, if a user schedules the restart in the update notification, it overrides this setting.
|
||
|
||
|
||
|
||
For a detailed description of these registry keys, see Registry keys used to manage restart.
|
||
|
||
|
||
|
||
## Configure active hours
|
||
|
||
|
||
|
||
*Active hours* identify the period of time when you expect the device to be in use. Automatic restarts after an update occur outside of the active hours.
|
||
|
||
|
||
|
||
By default, active hours are from 8 AM to 5 PM on PCs. Users can manually change the active hours.
|
||
|
||
|
||
|
||
You can also specify the max active hours range. The specified range is counted from the active hours start time.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
The max active hours length for Windows 10, version 1607 and Windows Server 2016 is 12. Later versions support max active hours length of 18 hours.
|
||
|
||
|
||
|
||
### Configure active hours with group policy
|
||
|
||
|
||
|
||
To configure active hours using group policy, go to **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and open the **Turn off auto-restart for updates during active hours** policy setting. When the policy is enabled, you can set the start and end times for active hours.
|
||
|
||
|
||
|
||
[](images/waas-active-hours-policy.png#lightbox)
|
||
|
||
|
||
|
||
### Configure active hours with MDM
|
||
|
||
|
||
|
||
To configure active hours, MDM uses the following settings in the [Update Policy CSP](/en-us/windows/client-management/mdm/policy-csp-update):
|
||
|
||
|
||
|
||
- [ActiveHoursStart](/en-us/windows/client-management/mdm/policy-csp-update#activehoursstart)
|
||
|
||
- [ActiveHoursEnd](/en-us/windows/client-management/mdm/policy-csp-update#activehoursend)
|
||
|
||
- [ActiveHoursMaxRange](/en-us/windows/client-management/mdm/policy-csp-update#activehoursmaxrange)
|
||
|
||
|
||
|
||
### Configure active hours through the Windows registry
|
||
|
||
|
||
|
||
This method isn't recommended, and should only be used when you can't use group policy or MDM. Any settings configured through the registry might conflict with any existing configuration that uses any of the other methods.
|
||
|
||
|
||
|
||
Configure active hours by setting a combination of the following registry values:
|
||
|
||
|
||
|
||
Under `HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate` use `SetActiveHours` to enable or disable active hours and `ActiveHoursStart` and `ActiveHoursEnd` to specify the range of active hours.
|
||
|
||
|
||
|
||
For a detailed description of these registry keys, see Registry keys used to manage restart.
|
||
|
||
|
||
|
||
Tip
|
||
|
||
|
||
|
||
To manually configure active hours on a device, go to **Settings** > **Windows Update** > **Advanced options** and select **Active hours**.
|
||
|
||
|
||
|
||
### Configure active hours maximum range
|
||
|
||
|
||
|
||
You can specify the maximum active hours range that users can set. This option gives you flexibility to leave some of the decision for active hours on the user's side, while making sure you allow enough time for updates to install. The maximum range is calculated from the active hours start time.
|
||
|
||
|
||
|
||
To configure the maximum range for active hours through group policy, go to **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and open the setting to **Specify active hours range for auto-restarts**.
|
||
|
||
|
||
|
||
To configure the maximum range for active hours through MDM, use [ActiveHoursMaxRange](/en-us/windows/client-management/mdm/policy-csp-update#activehoursmaxrange).
|
||
|
||
|
||
|
||
## Limit restart delays
|
||
|
||
|
||
|
||
After Windows installs an update, it attempts to automatically restart outside of active hours. If the restart doesn't succeed after a default period of seven days, the user sees a notification that a restart is required. To change the delay, use the setting to **Specify deadline before auto-restart for update installation**. The minimum value is two days and the maximum value is two weeks (14 days). This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
|
||
|
||
## Control restart notifications
|
||
|
||
|
||
|
||
### Display options for update notifications
|
||
|
||
|
||
|
||
You can define which Windows Update notifications are displayed to the user. This policy doesn't control how and when updates are downloaded and installed.
|
||
|
||
|
||
|
||
To configure this behavior through group policy, go to **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and select the policy for **Display options for update notifications**. Configure the following values:
|
||
|
||
|
||
|
||
- `0` (default): Use the default Windows Update notifications.
|
||
|
||
- `1`: Turn off most notifications but keep restart warnings.
|
||
|
||
- `2`: Turn off all notifications including restart warnings.
|
||
|
||
|
||
|
||
To configure this behavior through MDM, use [UpdateNotificationLevel](/en-us/windows/client-management/mdm/policy-csp-update#updatenotificationlevel).
|
||
|
||
|
||
|
||
Starting in Windows 11, version 22H2, **Apply only during active hours** was added as another option for **Display options for update notifications**. When you select **Apply only during active hours**, the notifications are only disabled during active hours when you use options `1` or `2`. To ensure that the device stays updated, a notification is still shown during active hours if you select **Apply only during active hours**, and once a deadline is reached when you configure [Specify deadlines for automatic updates and restarts](wufb-compliancedeadlines).
|
||
|
||
|
||
|
||
To configure this behavior through MDM, use [UpdateNotificationLevel](/en-us/windows/client-management/mdm/policy-csp-update#updatenotificationlevel).
|
||
|
||
|
||
|
||
### Automatic restart notifications
|
||
|
||
|
||
|
||
You can override the default behavior for the automatic restart required notification. By default, this notification dismisses automatically.
|
||
|
||
|
||
|
||
- To configure this behavior through group policy, go to **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and select the policy to **Configure auto-restart required notification for updates**. When configured to **2 - User Action**, a user that gets this notification must manually dismiss it. This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
- To configure this behavior through MDM, use [AutoRestartRequiredNotificationDismissal](/en-us/windows/client-management/mdm/policy-csp-update#autorestartrequirednotificationdismissal). This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
|
||
|
||
You can also configure the period before an update that this notification shows up. The default value is 15 minutes.
|
||
|
||
|
||
|
||
- To change it through group policy, select **Configure auto-restart-reminder notifications for updates** under **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and select the period in minutes. This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
- To change it through MDM, use [AutoRestartNotificationSchedule](/en-us/windows/client-management/mdm/policy-csp-update#autorestartnotificationschedule). This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
|
||
|
||
In some cases, you don't need a notification to show up.
|
||
|
||
|
||
|
||
- To do so through group policy, go to **Computer Configuration\Administrative Templates\Windows Components\Windows Update** and select the setting to **Turn off auto-restart notifications for update installations**. This policy is a legacy policy and isn't applicable for Windows 11. Legacy policies might be removed in a future release.
|
||
|
||
- To do so through MDM, use [SetAutoRestartNotificationDisable](/en-us/windows/client-management/mdm/policy-csp-update#setautorestartnotificationdisable). This policy is a legacy policy and isn't applicable for Windows 11. L
|
||
…[truncated 10075 chars]
|
||
|
||
## [SEARCH #29] 작업 스케줄러 "사용자의 로그온 여부에 관계없이 실행" "암호를 저장하지 않음" S4U 네트워크 접근 불가 PowerShell 스크립트 실행 안됨
|
||
|
||
Web search results for query: "작업 스케줄러 "사용자의 로그온 여부에 관계없이 실행" "암호를 저장하지 않음" S4U 네트워크 접근 불가 PowerShell 스크립트 실행 안됨"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #30] BurntToast 파워쉘 토스트 알림 윈도우11 버튼 클릭 실행 예제
|
||
|
||
Web search results for query: "BurntToast 파워쉘 토스트 알림 윈도우11 버튼 클릭 실행 예제"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #31] NSSM 파이썬 스크립트 윈도우 서비스 등록 재시작 로그 세션0 크롬 헤드리스
|
||
|
||
Web search results for query: "NSSM 파이썬 스크립트 윈도우 서비스 등록 재시작 로그 세션0 크롬 헤드리스"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [FETCH #37] https://www.ninjaone.com/blog/priority-notifications-for-do-not-disturb/
|
||
**ASK:** Extract: how to add an app to the Priority notifications list in Windows 11 (Settings path), the registry paths mentioned (HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings, NOC_GLOBAL_SETTING_TOASTS_ENABLED, per-app keys), and any PowerShell snippet to turn Do Not Disturb off or add priority apps.
|
||
|
||
# Windows 11 Priority Notifications Configuration
|
||
|
||
## Settings Path to Add Priority Apps
|
||
|
||
Navigate to **Settings > System > Notifications > Set priority notifications**, then click **Add apps** to include applications that will bypass Do Not Disturb mode.
|
||
|
||
## Registry Locations for Automation
|
||
|
||
The relevant registry paths are:
|
||
- **Main setting**: `HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings`
|
||
- **Key name**: `NOC_GLOBAL_SETTING_TOASTS_ENABLED`
|
||
- **Per-app configuration**: `HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\<App ID>`
|
||
|
||
## PowerShell Commands
|
||
|
||
**To disable Do Not Disturb:**
|
||
```powershell
|
||
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings" -Name "NOC_GLOBAL_SETTING_TOASTS_ENABLED" -Value 0 -PropertyType DWord -Force
|
||
```
|
||
|
||
**To enable Do Not Disturb:**
|
||
```powershell
|
||
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings" -Name "NOC_GLOBAL_SETTING_TOASTS_ENABLED" -Value 1 -PropertyType DWord -Force
|
||
```
|
||
|
||
## Important Notes
|
||
|
||
- Settings apply per-user and don't require administrator rights unless restricted by enterprise policy
|
||
- Test scripts in a sandbox environment before production deployment
|
||
- Some applications use independent notification systems that won't be affected by Windows 11's built-in Do Not Disturb feature
|
||
|
||
## [SEARCH #32] Docker Desktop Windows "Start Docker Desktop when you sign in" setting containers restart always after reboot
|
||
|
||
Web search results for query: "Docker Desktop Windows "Start Docker Desktop when you sign in" setting containers restart always after reboot"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #33] Task Scheduler "Run whether user is logged on or not" PowerShell script exit code 0x1 working directory "Start in" path fix
|
||
|
||
Web search results for query: "Task Scheduler "Run whether user is logged on or not" PowerShell script exit code 0x1 working directory "Start in" path fix"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [SEARCH #34] Playwright Python headless chromium scheduled task SYSTEM account browsers path PLAYWRIGHT_BROWSERS_PATH %USERPROFILE%\AppData\Local\ms-playwright not found
|
||
|
||
Web search results for query: "Playwright Python headless chromium scheduled task SYSTEM account browsers path PLAYWRIGHT_BROWSERS_PATH %USERPROFILE%\AppData\Local\ms-playwright not found"
|
||
|
||
Web search was not performed: this session has used its web search budget (200 of 200 WebSearch calls). Continue with the information already gathered instead of issuing more searches. If more searches are genuinely needed, ask the user to raise CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION.
|
||
|
||
|
||
REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
|
||
|
||
## [FETCH #38] https://learn.microsoft.com/en-us/windows/win32/taskschd/security-contexts-for-running-tasks
|
||
**ASK:** Summarize the page fully: security context of tasks, interactive vs non-interactive (password / S4U) logon, what 'highest privileges' means, network access limitations of S4U, and notes on tasks that display UI.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Security Contexts for Tasks - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/security-contexts-for-running-tasks
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Tasks are registered and run under a specific security context.
|
||
ms.assetid: be86eb9f-f6ec-4dce-afe8-e3314a74062a
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
locale: en-us
|
||
document_id: d3525a20-3b6b-4312-4999-fee9976f22bd
|
||
document_version_independent_id: 5bf84e71-33dc-2325-48e2-65b7a57f9694
|
||
updated_at: 2025-05-12T16:56:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/security-contexts-for-running-tasks.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/3b873c9d9d66e1f4c8dc2c2930d564c308235e5d/desktop-src/TaskSchd/security-contexts-for-running-tasks.md
|
||
git_commit_id: 3b873c9d9d66e1f4c8dc2c2930d564c308235e5d
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 1264
|
||
asset_id: taskschd/security-contexts-for-running-tasks
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/security-contexts-for-running-tasks.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/86a4b315-a9f1-4577-b985-6fb0e0e67420
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/96ac410d-d052-4707-8007-df31dd0fe041
|
||
platformId: eb0d276d-53c2-30ff-90d5-6f38ab6f43bb
|
||
---
|
||
|
||
# Security Contexts for Tasks - Win32 apps | Microsoft Learn
|
||
|
||
Tasks are registered and run under a specific security context. Users can create applications that successfully register, update, delete, or run tasks, but the user must supply the correct credentials when a task is registered and the application must be running in a process with the correct privileges.
|
||
|
||
|
||
|
||
## Specifying Credentials
|
||
|
||
|
||
|
||
You can specify the security context for a task by specifying credentials in the [**ITaskFolder::RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask) or [**ITaskFolder::RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition) ([**TaskFolder.RegisterTask**](taskfolder-registertask) or [**TaskFolder.RegisterTaskDefinition**](taskfolder-registertaskdefinition) for scripting) methods or by assigning a principal to the [**Principal Property of ITaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskdefinition-get_principal) ([**TaskDefinition.Principal**](taskdefinition-principal) for scripting). If a principal is created for a task definition, and then the task definition is registered using the **RegisterTaskDefinition** method with different credentials specified in the method parameters, then the credentials specified in the **RegisterTaskDefinition** method will overwrite the credentials in the principal. If a principal is created for a task definition using XML, and then the XML for the task is registered using the **RegisterTask** method with different credentials specified in the method parameters, then the credentials specified in the **RegisterTask** method will overwrite the credentials in the principal.
|
||
|
||
|
||
|
||
You specify a user account or group when registering a task or specifying the principle for a task. The security context of the user account or group is used for the security context of the task. In these methods and properties, you also define the logon type. The logon type is defined by one of the constants in the [**TASK\_LOGON\_TYPE**](/en-us/windows/desktop/api/taskschd/ne-taskschd-task_logon_type) enumeration.
|
||
|
||
|
||
|
||
Tasks registered with the TASK\_LOGON\_PASSWORD or TASK\_LOGON\_S4U flag will only launch if the specified user has the Logon as Batch privilege enabled. Administrators and Backup Operators group users have this privilege enabled by default.
|
||
|
||
|
||
|
||
When you call the [**ITaskService::Connect**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskservice-connect) ([**TaskService.Connect**](taskservice-connect) for scripting) method, any subsequent method calls to the Task Scheduler service will use the credentials that were passed to the **Connect** method. This is important to consider when registering tasks with an interactive logon type. When you register a task with the logon type equal to TASK\_LOGON\_INTERACTIVE\_TOKEN and the task does not have credentials specified in the [**Principal**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskdefinition-get_principal) property of the task definition, specified in the parameters to [**RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition), or specified in the XML that is passed to [**RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask), then the task will be registered with the credentials of the user that called the **Connect** method.
|
||
|
||
|
||
|
||
## User Account Control (UAC) Security for Tasks
|
||
|
||
|
||
|
||
[User Account Control](https://support.microsoft.com/topic/how-to-use-user-account-control-uac-in-windows-vista-33b5a65e-4238-397e-d1b4-c502ee0f473e) (UAC) lets users exercise general functionality such as running programs and saving and modifying data without exposing administrative privileges. By default, a task runs with low level privileges when UAC is turned on. Tasks can specify that they will run with elevated privileges or low privileges by setting a privilege level from the [**TASK\_RUNLEVEL\_TYPE**](/en-us/windows/win32/api/taskschd/ne-taskschd-task_runlevel_type) enumeration for the [**RunLevel property of IPrincipal**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iprincipal-get_runlevel) ([**Principal.RunLevel**](principal-runlevel) for scripting). The value of the **RunLevel** property determines the privilege level at which a task's actions will be run. If a task's actions must have elevated privileges to run, then you must set the **RunLevel** property to **TASK\_RUNLEVEL\_HIGHEST**. If a task is registered using the Administrators group for the security context of the task, then you must also set the **RunLevel** property to **TASK\_RUNLEVEL\_HIGHEST** if you want to run the task. If a task is registered using the Builtin\Administrator account or the Local System or Local Service accounts, then the **RunLevel** property will be ignored. The property value will also be ignored if User Account Control (UAC) is turned off. The value of the **RunLevel** property doesn't affect the permissions needed to run or delete a task.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
After upgrading an operating system from Windows XP to Windows Vista, tasks that were registered using the Builtin\Administrator account on Windows XP will have the [**RunLevel**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iprincipal-get_runlevel) property set to **TASK\_RUNLEVEL\_LUA**. This might cause some tasks to fail. You can update this property manually to ensure all the tasks will run.
|
||
|
||
|
||
|
||
From a low privilege process, you cannot register a task with the [**RunLevel**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iprincipal-get_runlevel) property equal to **TASK\_RUNLEVEL\_HIGHEST**, but you can register a task with the **RunLevel** property equal to **TASK\_RUNLEVEL\_LUA**. The task actions will be run with low privileges. You are not allowed to register the task as Builtin/Administrator, Local System, or for a group.
|
||
|
||
|
||
|
||
From an elevated privilege process, you can register a task with the [**RunLevel**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iprincipal-get_runlevel) property equal to **TASK\_RUNLEVEL\_HIGHEST** or **TASK\_RUNLEVEL\_LUA**. The task will be run with a privilege level decided by the **RunLevel** property unless you are using the Administrator account, in which case the task is run with elevated privileges.
|
||
|
||
|
||
|
||
From an elevated process, you can register a Task Scheduler 1.0 task. The Task Scheduler service will set the run level of the task to TASK\_RUNLEVEL\_HIGHEST and the task will run with elevated privileges.
|
||
|
||
|
||
|
||
From a low privilege process, you can also register a Task Scheduler 1.0 task. The Task Scheduler service will set the run level of the task to TASK\_RUNLEVEL\_LUA, and the task will run with low privileges. If this task is updated from an elevated process, the run level of the task will remain TASK\_RUNLEVEL\_LUA.
|
||
|
||
|
||
|
||
## Security for Registering Tasks
|
||
|
||
|
||
|
||
When you register a task from an account that is a member of the Administrators group, then you only need to specify a password while registering the task in the following situations:
|
||
|
||
|
||
|
||
- If you register the task to run under the security context of your account or a different user's account and you use the TASK\_LOGON\_PASSWORD flag in the [**RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask) or [**RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition) method.
|
||
|
||
- If you register the task to run under the security context of a different user's account and you use the TASK\_LOGON\_S4U flag in the [**RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask) or [**RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition) method.
|
||
|
||
|
||
|
||
You cannot use a user group as the security context of a task when you register the task using the TASK\_LOGON\_S4U flag or the TASK\_LOGON\_PASSWORD flag in the [**RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask) or [**RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition) method.
|
||
|
||
|
||
|
||
When you register a task from a user account that is not a member of the Administrators group, then you do not need to specify a password when registering the task if you register the task to run under the security context of your account and you use the S4U or interactive logon type. Otherwise, you need to specify a password when registering the task. Also, you cannot register the task using the Local Service account or by using a group for the task's security context.
|
||
|
||
|
||
|
||
## Security for Reading, Updating, Deleting, and Running Tasks
|
||
|
||
|
||
|
||
By default, a user who creates a task can read, update, delete, and run the task. A user must have file write permission on a task file to update a task, file read permission on a task file to read a task, delete permission on a task file to delete a task, and file execute permission on a task to run a task using the [**IRegisteredTask::Run**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iregisteredtask-run) or [**RunEx**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iregisteredtask-runex) methods ([**RegisteredTask.Run**](registeredtask-run) and [**RunEx**](registeredtask-runex) for scripting). Members of the Administrators group or the SYSTEM account can read, update, delete, and run any tasks. Members of the Users group, the LocalService account, and the NetworkService account can only read, update, delete, and run the tasks that they have created. This default behavior is changed when the DACL of the task file is changed, in which case the DACL defines which users have file write, read, execute, and delete permission. To set permissions for a task file, use the IRegisteredTask.SetSecurityDescriptor method (RegisteredTask.SetSecurityDescriptor for scripting) or set the security descriptor when you register the task using the [**RegisterTask**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertask) or [**RegisterTaskDefinition**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itaskfolder-registertaskdefinition) methods.
|
||
|
||
|
||
|
||
A user must have WriteDAC permission in addition to the read/write permissions to update a task if the task update requires a change to the DACL for the task.
|
||
|
||
## [FETCH #39] https://raw.githubusercontent.com/Windos/BurntToast/main/Help/New-BTButton.md
|
||
**ASK:** Give the syntax and parameters of New-BTButton (Content, Arguments, ActivationType and accepted values, Snooze, Dismiss, ImageUri, Id, Color, HintInputId) and the examples verbatim.
|
||
|
||
# New-BTButton Syntax and Parameters
|
||
|
||
## Syntax
|
||
```powershell
|
||
New-BTButton [-Snooze] [-Dismiss] [-Content <String>] [-Arguments <String>]
|
||
[-ActivationType <Microsoft.Toolkit.Uwp.Notifications.ToastActivationType>]
|
||
[-ImageUri <String>] [-Id <String>] [-Color <String>]
|
||
```
|
||
|
||
## Parameters
|
||
|
||
| Parameter | Type | Description |
|
||
|-----------|------|-------------|
|
||
| `Snooze` | Switch | "Creates a system-handled snooze button" |
|
||
| `Dismiss` | Switch | "Creates a system-handled dismiss button" |
|
||
| `Content` | String | "The text to display on this button" |
|
||
| `Arguments` | String | "App-defined string to pass when the button is pressed" |
|
||
| `ActivationType` | ToastActivationType | "Defines the activation type that triggers when the button is pressed. Defaults to Protocol" |
|
||
| `ImageUri` | String | "Path or URI of an image icon to display next to the button label" |
|
||
| `Id` | String | "Specifies an ID associated with another toast control" |
|
||
| `Color` | String | Accepted values: `Green` or `Red` for styled actions |
|
||
|
||
## Examples
|
||
|
||
**Example 1:** `New-BTButton -Dismiss`
|
||
|
||
**Example 2:** `New-BTButton -Snooze`
|
||
|
||
**Example 3:** `New-BTButton -Snooze -Content 'Sleep' -Id 'TimeSelection'`
|
||
|
||
**Example 4:** `New-BTButton -Content 'Blog' -Arguments 'https://king.geek.nz'`
|
||
|
||
**Example 5:** `$pic = 'C:\temp\example.png'; New-BTButton -Content 'View Picture' -Arguments $pic -ImageUri $pic`
|
||
|
||
**Example 6:** `New-BTButton -Content 'Approve' -Arguments 'approve' -Color Green`
|
||
|
||
**Example 7:** `New-BTButton -Content 'Delete' -Arguments 'delete' -Color Red`
|
||
|
||
## [FETCH #40] https://raw.githubusercontent.com/Windos/BurntToast/main/README.md
|
||
**ASK:** Summarize: install command, requirements (Windows/PowerShell versions), links to docs site, any FAQ/known-limitations about running as SYSTEM, from Task Scheduler, or from a non-interactive session, and the mention of Urgent/Important notifications and button examples.
|
||
|
||
# BurntToast Summary
|
||
|
||
## Installation
|
||
The primary installation method is via PowerShell Gallery: `Install-Module -Name BurntToast`. Alternatively, Chocolatey users can run `choco install burnttoast-psmodule`.
|
||
|
||
## Requirements
|
||
BurntToast supports "Windows 10 and Windows Server 2019 and above." The documentation doesn't specify minimum PowerShell versions, though v1.0.0 notes improvements for "Windows PowerShell" and PowerShell 7.1+.
|
||
|
||
## Documentation & Contact
|
||
No dedicated docs site link appears on this page. For more information, contact the maintainer via Bluesky (@toastit.dev), Mastodon, Twitter (@WindosNZ), or the blog ToastIT.dev.
|
||
|
||
## Key Features
|
||
Recent releases introduced support for "Important Notifications using the Urgent switch" and "setting button colors." The page doesn't provide specific FAQ or known limitations regarding SYSTEM account execution, Task Scheduler deployment, or non-interactive sessions.
|
||
|
||
## Notable Changes
|
||
Version 1.0.0 removed custom audio paths, AppId customization, and shoulder tap notifications—representing significant breaking changes for existing users.
|
||
|
||
## [FETCH #41] https://playwright.dev/python/docs/browsers
|
||
**ASK:** Extract: the default browser download location on Windows (%USERPROFILE%\AppData\Local\ms-playwright), the PLAYWRIGHT_BROWSERS_PATH environment variable and how it is used at install and at runtime, 'playwright install chromium', '--with-deps', and chromium-headless-shell / 'playwright install chromium --only-shell' notes.
|
||
|
||
# Playwright Browser Management Overview
|
||
|
||
## Default Windows Download Location
|
||
|
||
On Windows systems, Playwright automatically stores browser binaries in `"%USERPROFILE%\AppData\Local\ms-playwright"` unless configured otherwise.
|
||
|
||
## PLAYWRIGHT_BROWSERS_PATH Environment Variable
|
||
|
||
This variable allows customization of where browsers are installed and searched for:
|
||
|
||
**During Installation:** Set the variable before running `playwright install` to direct downloads to a custom directory:
|
||
```bash
|
||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
|
||
```
|
||
|
||
**At Runtime:** When executing Playwright scripts, the same variable tells Playwright where to locate previously installed browsers:
|
||
```bash
|
||
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.py
|
||
```
|
||
|
||
## Installing Chromium Specifically
|
||
|
||
To install only Chromium rather than all supported browsers, use:
|
||
```bash
|
||
playwright install chromium
|
||
```
|
||
|
||
## Combined Installation with Dependencies
|
||
|
||
The `--with-deps` flag installs both browser binaries and required system dependencies in a single command:
|
||
```bash
|
||
playwright install --with-deps chromium
|
||
```
|
||
|
||
## Chromium Headless Shell Optimization
|
||
|
||
Playwright ships separate builds for headed and headless modes. To reduce download size when running tests only in headless mode, use the `--only-shell` flag to "avoid downloading the full Chromium browser."
|
||
|
||
## [FETCH #42] https://docs.docker.com/desktop/settings-and-maintenance/settings/
|
||
**ASK:** Find the General settings: 'Start Docker Desktop when you sign in to your computer' (exact wording), 'Open Docker Dashboard when Docker Desktop starts', and any note that Docker Desktop on Windows requires a user sign-in / cannot run as a service before login.
|
||
|
||
# Docker Desktop General Settings
|
||
|
||
Based on the documentation, here are the relevant General settings:
|
||
|
||
**"Start Docker Desktop when you sign in to your computer"** — This setting automatically launches Docker Desktop upon user login. It's disabled by default but recommended for those who use Docker frequently.
|
||
|
||
**"Open Docker Dashboard when Docker Desktop starts"** — This feature automatically opens the dashboard when Docker Desktop launches. It's also disabled by default.
|
||
|
||
**Note on Windows Service Behavior:** The documentation does not contain any statement indicating that Docker Desktop on Windows requires user sign-in or cannot operate as a service before login. The provided content focuses on the settings themselves rather than Windows service constraints.
|
||
|
||
## [FETCH #43] https://learn.microsoft.com/en-us/windows/wsl/wsl-config
|
||
**ASK:** Extract the wsl.conf [boot] section options: systemd and command (e.g. command = service docker start), with exact syntax and notes about when the command runs. Also .wslconfig options related to vmIdleTimeout if present.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Advanced settings configuration in WSL | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/wsl/wsl-config
|
||
breadcrumb_path: /windows/wsl/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-Windows-DevTools
|
||
recommendations: true
|
||
feedback_product_url: https://github.com/microsoft/WSL/issues
|
||
feedback_system: OpenSource
|
||
ms.service: dev-environment
|
||
ms.subservice: windows-subsystem-for-linux
|
||
author: GrantMeStrength
|
||
ms.author: jken
|
||
ms.reviewer: crloewen
|
||
adobe-target: true
|
||
description: A guide to the wsl.conf and .wslconfig files used for configuring settings when running multiple Linux distributions on Windows Subsystem for Linux.
|
||
ms.date: 2026-04-15T00:00:00.0000000Z
|
||
ms.topic: article
|
||
locale: en-us
|
||
document_id: deab370f-a7a1-ed3f-89ae-22194fd8fb78
|
||
document_version_independent_id: 9f406c77-415c-80db-d596-0a7fa4ea2ba9
|
||
updated_at: 2026-06-02T16:58:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/WSL/blob/live/WSL/wsl-config.md
|
||
gitcommit: https://github.com/MicrosoftDocs/WSL/blob/7b28cc1ee9b8ff672ada5e1c6c326d3573d703e5/WSL/wsl-config.md
|
||
git_commit_id: 7b28cc1ee9b8ff672ada5e1c6c326d3573d703e5
|
||
site_name: Docs
|
||
depot_name: WS.wsl
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/WS.wsl/{branchName}{pdfName}
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
word_count: 3361
|
||
asset_id: wsl-config
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: WSL/wsl-config.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 217cb7e3-3b14-fce2-8728-2aa20524a9bc
|
||
---
|
||
|
||
# Advanced settings configuration in WSL | Microsoft Learn
|
||
|
||
The `wsl.conf` and `.wslconfig` files are used to configure advanced settings in WSL that will be applied on start up of the WSL VM. `wsl.conf` is used to apply settings on a per WSL distro basis, and `.wslconfig` is used to apply global settings to WSL. You can read more about the differences below.
|
||
|
||
|
||
|
||
| Aspect | `.wslconfig` | `wsl.conf` |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| Scope | General settings that apply to all of WSL | Settings for WSL distributions only |
|
||
|
||
| Configures | Feature enablement in WSL, settings for the virtual machine powering WSL 2 (RAM, kernel to boot, number of CPUs, etc.) | Distribution settings in WSL such as boot options, DrvFs automounts, networking, interoperability with the Windows system, systemd usage, and default user |
|
||
|
||
| Location | `%UserProfile%\.wslconfig`, outside of a WSL distribution | `/etc/wsl.conf`, while inside a WSL distribution |
|
||
|
||
|
||
|
||
Currently, all `.wslconfig` settings apply only to WSL 2 distributions. Learn [how to check which version of WSL you are running](install#check-which-version-of-wsl-you-are-running).
|
||
|
||
|
||
|
||
## The 8 second rule for configuration changes
|
||
|
||
|
||
|
||
You must wait until the subsystem running your Linux distribution completely stops running and restarts for configuration setting updates to appear. This typically takes about 8 seconds after closing ALL instances of the distribution shell.
|
||
|
||
|
||
|
||
If you launch a distribution (e.g. Ubuntu), modify the configuration file, close the distribution, and then re-launch it, you might assume that your configuration changes have immediately gone into effect. This is not currently the case as the subsystem could still be running. You must wait for the subsystem to stop before relaunching in order to give enough time for your changes to be picked up. You can check to see whether your Linux distribution (shell) is still running after closing it by using PowerShell with the command: `wsl --list --running`. If no distributions are running, you will receive the response: "There are no running distributions." You can now restart the distribution to see your configuration updates applied.
|
||
|
||
|
||
|
||
The command `wsl --shutdown` is a fast path to restarting WSL 2 distributions, but it will shut down all running distributions, so use wisely. You can also use `wsl --terminate <distroName>` to terminate a specific distribution that's running instantly.
|
||
|
||
|
||
|
||
## wsl.conf
|
||
|
||
|
||
|
||
Configure **local settings** with **wsl.conf** per-distribution for each Linux distribution running on WSL 1 or WSL 2.
|
||
|
||
|
||
|
||
- Stored in the `/etc` directory of the distribution as a unix file.
|
||
|
||
- Used to configure settings on a per-distribution basis. Settings configured in this file will only be applied to the specific Linux distribution that contains the directory where this file is stored.
|
||
|
||
- Can be used for distributions run by either version, WSL 1 or WSL 2.
|
||
|
||
- To get to the `/etc` directory for an installed distribution, use the distribution's command line with `cd /` to access the root directory, then `ls` to list files or `explorer.exe .` to view in Windows File Explorer. The directory path should look something like: `/etc/wsl.conf`.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
Adjusting per-distribution settings with the wsl.conf file is only available in Windows Build 17093 and later.
|
||
|
||
|
||
|
||
### Configuration settings for wsl.conf
|
||
|
||
|
||
|
||
The wsl.conf file configures settings on a per-distribution basis. *(For global configuration of WSL 2 distributions see .wslconfig).*
|
||
|
||
|
||
|
||
The wsl.conf file supports four sections: `automount`, `network`, `interop`, and `user`. *(Modeled after .ini file conventions, keys are declared under a section, like .gitconfig files.)* See wsl.conf for info on where to store the wsl.conf file.
|
||
|
||
|
||
|
||
### systemd support
|
||
|
||
|
||
|
||
Many Linux distributions run "systemd" by default (including Ubuntu). WSL supports this system/service manager on recent versions of WSL from the Microsoft Store, making WSL even more similar to using your favorite Linux distributions on a bare metal machine. Check your WSL version with `wsl --version`. If you need to update, you can grab the [latest version of WSL in the Microsoft Store](https://aka.ms/wslstorepage). If `wsl --version` is not recognized, you are likely using an older inbox version of WSL that must be updated before systemd is available.
|
||
|
||
|
||
|
||
To enable systemd, open your `wsl.conf` file in a text editor using `sudo` for admin permissions and add these lines to the `/etc/wsl.conf`:
|
||
|
||
|
||
|
||
```bash
|
||
|
||
[boot]
|
||
|
||
systemd=true
|
||
|
||
```
|
||
|
||
|
||
|
||
You will then need to close your WSL distribution using `wsl.exe --shutdown` from PowerShell to restart your WSL instances. Once your distribution restarts, systemd should be running. You can confirm using the command: `systemctl list-unit-files --type=service`, which will show the status of your services.
|
||
|
||
|
||
|
||
### Automount settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[automount]`
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `enabled` | boolean | `true` | `true` causes fixed drives (i.e `C:/` or `D:/`) to be automatically mounted with DrvFs under `/mnt`. `false` means drives won't be mounted automatically, but you could still mount them manually or via `fstab`. |
|
||
|
||
| `mountFsTab` | boolean | `true` | `true` sets `/etc/fstab` to be processed on WSL start. `/etc/fstab` is a file where you can declare other filesystems, like an SMB share. Thus, you can mount these filesystems automatically in WSL on start up. |
|
||
|
||
| `root` | string | `/mnt/` | Sets the directory where fixed drives will be automatically mounted. By default this is set to `/mnt/`, so your Windows file system `C:\` is mounted to `/mnt/c/`. If you change `/mnt/` to `/windir/`, you should expect to see your fixed `C:\` mounted to `/windir/c`. |
|
||
|
||
| `options` | comma-separated list of values, such as uid, gid, etc, see automount options below | Null | The automount option values are listed below and are appended to the default DrvFs mount options string. **Only DrvFs-specific options can be specified.** |
|
||
|
||
|
||
|
||
The automount options are applied as the mount options for all automatically mounted drives. To change the options for a specific drive only, use the `/etc/fstab` file instead. Options that the mount binary would normally parse into a flag are not supported. If you want to explicitly specify those options, you must include every drive for which you want to do so in `/etc/fstab`.
|
||
|
||
|
||
|
||
#### Automount options
|
||
|
||
|
||
|
||
Setting different mount options for Windows drives (DrvFs) can control how file permissions are calculated for Windows files. The following options are available:
|
||
|
||
|
||
|
||
| Key | Description | Default |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| `uid` | The User ID used for the owner of all files | The default User ID of your WSL distro (on first installation this defaults to `1000`) |
|
||
|
||
| `gid` | The Group ID used for the owner of all files | The default group ID of your WSL distro (on first installation this defaults to `1000`) |
|
||
|
||
| `umask` | An octal mask of permissions to exclude for all files and directories | `022` |
|
||
|
||
| `fmask` | An octal mask of permissions to exclude for all files | `000` |
|
||
|
||
| `dmask` | An octal mask of permissions to exclude for all directories | `000` |
|
||
|
||
| `metadata` | Whether metadata is added to Windows files to support Linux system permissions | `disabled` |
|
||
|
||
| `case` | Determines directories treated as case sensitive and whether new directories created with WSL will have the flag set. See [case sensitivity](case-sensitivity) for a detailed explanation of the options. Options include `off`, `dir`, or `force`. | `off` |
|
||
|
||
|
||
|
||
By default, WSL sets the `uid` and `gid` to the value of the default user. For example, in Ubuntu, the default user is `uid=1000`, `gid=1000`. If this value is used to specify a different `gid` or `uid` option, the default user value will be overwritten. Otherwise, the default value will always be appended.
|
||
|
||
|
||
|
||
The above umask, fmask, etc. options will only apply when the Windows drive is mounted with metadata. By default metadata is not enabled. You can [find more info about this here](file-permissions).
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
The permission masks are put through a logical OR operation before being applied to files or directories.
|
||
|
||
|
||
|
||
#### What is DrvFs?
|
||
|
||
|
||
|
||
DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem. DrvFs enables WSL to mount drives with supported file systems under /mnt, such as /mnt/c, /mnt/d, etc. For more information about specifying the default case sensitivity behavior when mounting Windows or Linux drives or directories, see the [case sensitivity](case-sensitivity) page.
|
||
|
||
|
||
|
||
### Network settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[network]`
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `generateHosts` | boolean | `true` | `true` sets WSL to generate `/etc/hosts`. The `hosts` file contains a static map of hostnames corresponding IP address. |
|
||
|
||
| `generateResolvConf` | boolean | `true` | `true` sets WSL to generate `/etc/resolv.conf`. The `resolv.conf` contains a DNS list that are capable of resolving a given hostname to its IP address. |
|
||
|
||
| `hostname` | string | Windows hostname | Sets hostname to be used for WSL distribution. |
|
||
|
||
|
||
|
||
### Interop settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[interop]`
|
||
|
||
|
||
|
||
These options are available in Windows 10 version 1809 (build 17763) and later.
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `enabled` | boolean | `true` | Setting this key will determine whether WSL will support launching Windows processes. |
|
||
|
||
| `appendWindowsPath` | boolean | `true` | Setting this key will determine whether WSL will add Windows path elements to the `$PATH` environment variable. |
|
||
|
||
|
||
|
||
### User settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[user]`
|
||
|
||
|
||
|
||
These options are available in Build 18980 and later.
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `default` | string | The initial username created on first run | Setting this key specifies which user to run as when first starting a WSL session. |
|
||
|
||
|
||
|
||
### Boot settings
|
||
|
||
|
||
|
||
The Boot setting is only available on Windows 11 and Server 2022.
|
||
|
||
|
||
|
||
wsl.conf section label: `[boot]`
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `command` | string | Null | A string of the command that you would like to run when the WSL instance starts. This command is run as the root user. e.g: `service docker start`. |
|
||
|
||
| `protectBinfmt` | boolean | `true` | Prevents WSL from generating systemd units when systemd is enabled. |
|
||
|
||
|
||
|
||
### GPU settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[gpu]`
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `enabled` | boolean | `true` | Allow Linux applications to access the Windows GPU via para-virtualization. |
|
||
|
||
|
||
|
||
### Time settings
|
||
|
||
|
||
|
||
wsl.conf section label: `[time]`
|
||
|
||
|
||
|
||
| Key | Value | Default | Notes |
|
||
|
||
| --- | --- | --- | --- |
|
||
|
||
| `useWindowsTimezone` | boolean | `true` | Setting this key will make WSL use and sync to the timezone set in Windows. |
|
||
|
||
|
||
|
||
### Example wsl.conf file
|
||
|
||
|
||
|
||
The `wsl.conf` sample file below demonstrates some of the configuration options available. In this example, the distribution is Ubuntu-20.04 and the file path is `\\wsl.localhost\Ubuntu-20.04\etc\wsl.conf`.
|
||
|
||
|
||
|
||
```bash
|
||
|
||
# Automatically mount Windows drive when the distribution is launched
|
||
|
||
[automount]
|
||
|
||
|
||
|
||
# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
|
||
|
||
enabled=true
|
||
|
||
|
||
|
||
# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c.
|
||
|
||
root = /
|
||
|
||
|
||
|
||
# DrvFs-specific options can be specified.
|
||
|
||
options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"
|
||
|
||
|
||
|
||
# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
|
||
|
||
mountFsTab=true
|
||
|
||
|
||
|
||
# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.co
|
||
…[truncated 11433 chars]
|
||
|
||
## [FETCH #44] https://learn.microsoft.com/en-us/windows/win32/TaskSchd/taskschedulerschema-delay-boottriggertype-element
|
||
**ASK:** Give the definition of the Delay element for bootTriggerType: type, default value, format, and an XML example if any.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Delay (bootTriggerType) Element - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-delay-boottriggertype-element
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Specifies the amount of time between when the system is booted and when the task is started.
|
||
ms.assetid: 2a583069-ad38-43b4-bcf2-f7c9101f1927
|
||
keywords:
|
||
- Delay element Task Scheduler
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- Delay
|
||
api_type:
|
||
- Schema
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
api_location:
|
||
locale: en-us
|
||
document_id: ed09ecfd-7401-d471-502d-8f16efd01e4d
|
||
document_version_independent_id: b1fcd537-cc9e-7b3f-f2b5-79f21ebbc8c8
|
||
updated_at: 2020-12-11T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/taskschedulerschema-delay-boottriggertype-element.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/2ec0df659644a793ed4f6160f238a95c9d9a9dcf/desktop-src/TaskSchd/taskschedulerschema-delay-boottriggertype-element.md
|
||
git_commit_id: 2ec0df659644a793ed4f6160f238a95c9d9a9dcf
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 183
|
||
asset_id: taskschd/taskschedulerschema-delay-boottriggertype-element
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/taskschedulerschema-delay-boottriggertype-element.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 3723987d-2eaf-6a33-82a3-a74c929e5ab8
|
||
---
|
||
|
||
# Delay (bootTriggerType) Element - Win32 apps | Microsoft Learn
|
||
|
||
Specifies the amount of time between when the system is booted and when the task is started. The format for this string is PnYnMnDTnHnMnS, where nY is the number of years, nM is the number of months, nD is the number of days, 'T' is the date/time separator, nH is the number of hours, nM is the number of minutes, and nS is the number of seconds (for example, PT5M specifies 5 minutes and P1M4DT2H5M specifies one month, four days, two hours, and five minutes). For more information about the duration type, see https://go.microsoft.com/fwlink/p/?linkid=106886.
|
||
|
||
|
||
|
||
```syntax
|
||
|
||
<xs:element name="Delay"
|
||
|
||
type="duration"
|
||
|
||
/>
|
||
|
||
```
|
||
|
||
|
||
|
||
The **Delay** element is defined by the [**bootTriggerType**](taskschedulerschema-boottriggertype-complextype) complex type.
|
||
|
||
|
||
|
||
## Parent element
|
||
|
||
|
||
|
||
| Element | Derived from | Description |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| [**BootTrigger**](taskschedulerschema-boottrigger-triggergroup-element) | [**bootTriggerType**](taskschedulerschema-boottriggertype-complextype) | Specifies a trigger that starts a task when the system is booted. |
|
||
|
||
|
||
|
||
## Remarks
|
||
|
||
|
||
|
||
For script development, the event trigger delay is specified by the [**BootTrigger.Delay**](boottrigger-delay) property.
|
||
|
||
|
||
|
||
For C++ development, the event trigger delay is specified by the [**IBootTrigger::Delay**](/en-us/windows/desktop/api/taskschd/nf-taskschd-iboottrigger-get_delay) property.
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
## [FETCH #45] https://windows-toasts.readthedocs.io/en/latest/getting_started.html
|
||
**ASK:** Extract: pip install command, Python version requirement, minimal code example (WindowsToaster, Toast, text_fields, show_toast), InteractableWindowsToaster example with ToastButton and on_activated, and any AUMID / Task Scheduler / service caveats.
|
||
|
||
# Windows-Toasts Quick Reference
|
||
|
||
## Installation & Requirements
|
||
|
||
**Python Version:** The library requires "Python 3.9 or later" and "supports Windows 10 and 11."
|
||
|
||
**Installation Command:**
|
||
```bash
|
||
python -m pip install windows-toasts
|
||
```
|
||
|
||
## Basic Implementation
|
||
|
||
Here's the minimal code needed to display a notification:
|
||
|
||
```python
|
||
from windows_toasts import WindowsToaster, Toast
|
||
|
||
toaster = WindowsToaster('Python')
|
||
newToast = Toast()
|
||
newToast.text_fields = ['Hello, World!']
|
||
toaster.show_toast(newToast)
|
||
```
|
||
|
||
The key components are:
|
||
- **WindowsToaster**: Initializes the toaster with an app identifier
|
||
- **Toast**: Creates the notification object
|
||
- **text_fields**: Sets notification body content as a list
|
||
- **show_toast()**: Displays the notification
|
||
|
||
## Interactive Toasts
|
||
|
||
The documentation mentions an "InteractableWindowsToaster" class for interactive notifications with ToastButton elements and on_activated callbacks, though detailed examples aren't provided in this excerpt.
|
||
|
||
## Important Caveats
|
||
|
||
The page references sections on "Custom AUMIDs," "Advanced usage," and "Problem solving" that address AUMID configuration, Task Scheduler integration, and service-related considerations—suggesting these may be important for production deployments but aren't detailed in the getting started section.
|
||
|
||
## [FETCH #46] https://learn.microsoft.com/en-us/powershell/module/Microsoft.powershell.management/write-eventlog?view=powershell-5.1
|
||
**ASK:** Give the syntax of Write-EventLog (-LogName, -Source, -EventId, -EntryType values, -Message, -Category, -RawData) and the example; note the requirement that the source must be registered first with New-EventLog.
|
||
|
||
---
|
||
layout: Reference
|
||
monikers:
|
||
- powershell-5.1
|
||
defaultMoniker: powershell-5.1
|
||
versioningType: Ranged
|
||
title: Write-EventLog (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/write-eventlog?view=powershell-5.1
|
||
config_moniker_range: powershell-5.1
|
||
uid: Microsoft.PowerShell.Management.Write-EventLog
|
||
module: Microsoft.PowerShell.Management
|
||
description: 'The Write-EventLog cmdlet writes an event to an event log. To write an event to an event log, the event log must exist on the computer and the source must be registered for the event log. The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of the Windows operating system, use the Get-WinEvent cmdlet. '
|
||
ROBOTS: INDEX, FOLLOW
|
||
apiPlatform: powershell
|
||
archive_url: https://learn.microsoft.com/previous-versions/powershell/scripting/overview
|
||
breadcrumb_path: /powershell/scripting/bread/toc.json
|
||
feedback_product_url: https://github.com/PowerShell/PowerShell/issues/new/choose
|
||
feedback_help_link_url: https://learn.microsoft.com/powershell/scripting/community/community-support
|
||
feedback_help_link_type: ask-the-community
|
||
feedback_system: OpenSource
|
||
hideScope: false
|
||
author: sdwheeler
|
||
ms.author: sewhee
|
||
manager: jasongroce
|
||
ms.devlang: powershell
|
||
ms.service: powershell
|
||
ms.tgt_pltfr: windows, macos, linux
|
||
ms.update-cycle: 365-days
|
||
toc_preview: true
|
||
uhfHeaderId: MSDocsHeader-Powershell
|
||
ms.topic: reference
|
||
products:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/8bce367e-2e90-4b56-9ed5-5e4e9f3a2dc3
|
||
document type: cmdlet
|
||
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
|
||
HelpUri: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/write-eventlog?view=powershell-5.1&WT.mc_id=ps-gethelp
|
||
Locale: en-us
|
||
Module Name: Microsoft.PowerShell.Management
|
||
ms.date: 2017-06-09T00:00:00.0000000Z
|
||
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
|
||
document_id: 48528370-595d-20a1-024a-e2cfdc42db2c
|
||
document_version_independent_id: 788288b6-b6f8-804d-3252-51b5f23d9980
|
||
updated_at: 2022-09-19T22:00:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/live/reference/5.1/Microsoft.PowerShell.Management/Write-EventLog.md
|
||
gitcommit: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/8047ffc48965b0f201d83e8cfbc3d9ba3c0cc780/reference/5.1/Microsoft.PowerShell.Management/Write-EventLog.md
|
||
git_commit_id: 8047ffc48965b0f201d83e8cfbc3d9ba3c0cc780
|
||
default_moniker: powershell-5.1
|
||
site_name: Docs
|
||
depot_name: PowerShell.PowerShell_PowerShell-docs_reference
|
||
in_right_rail: h2h3
|
||
page_type: powershell
|
||
page_kind: command
|
||
toc_rel: ../psdocs/toc.json
|
||
asset_id: module/microsoft.powershell.management/write-eventlog
|
||
moniker_range_name: 5c70fd29722c65e9f104798d23172c2d
|
||
monikers:
|
||
- powershell-5.1
|
||
item_type: Content
|
||
source_path: reference/5.1/Microsoft.PowerShell.Management/Write-EventLog.md
|
||
cmProducts: []
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 4394647e-311b-6be3-b1d4-3115f6160101
|
||
---
|
||
|
||
# Write-EventLog
|
||
|
||
|
||
|
||
- Module:
|
||
|
||
- [Microsoft.PowerShell.Management Module](./)
|
||
|
||
|
||
|
||
Writes an event to an event log.
|
||
|
||
|
||
|
||
## Syntax
|
||
|
||
|
||
|
||
### Default (Default)
|
||
|
||
|
||
|
||
```Syntax
|
||
|
||
Write-EventLog
|
||
|
||
[-LogName] <String>
|
||
|
||
[-Source] <String>
|
||
|
||
[[-EntryType] <EventLogEntryType>]
|
||
|
||
[-Category <Int16>]
|
||
|
||
[-EventId] <Int32>
|
||
|
||
[-Message] <String>
|
||
|
||
[-RawData <Byte[]>]
|
||
|
||
[-ComputerName <String>]
|
||
|
||
[<CommonParameters>]
|
||
|
||
```
|
||
|
||
|
||
|
||
## Description
|
||
|
||
|
||
|
||
The `Write-EventLog` cmdlet writes an event to an event log.
|
||
|
||
|
||
|
||
To write an event to an event log, the event log must exist on the computer and the source must be registered for the event log.
|
||
|
||
|
||
|
||
The cmdlets that contain the **EventLog** noun (the **EventLog** cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of the Windows operating system, use the `Get-WinEvent` cmdlet.
|
||
|
||
|
||
|
||
## Examples
|
||
|
||
|
||
|
||
### Example 1: Write an event to the Application event log
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\> Write-EventLog -LogName "Application" -Source "MyApp" -EventID 3001 -EntryType Information -Message "MyApp added a user-requested feature to the display." -Category 1 -RawData 10,20
|
||
|
||
```
|
||
|
||
|
||
|
||
This command writes an event from the MyApp source to the Application event log.
|
||
|
||
|
||
|
||
### Example 2: Write an event to the Application event log of a remote computer
|
||
|
||
|
||
|
||
```
|
||
|
||
PS C:\> Write-EventLog -ComputerName "Server01" -LogName Application -Source "MyApp" -EventID 3001 -Message "MyApp added a user-requested feature to the display."
|
||
|
||
```
|
||
|
||
|
||
|
||
This command writes an event from the MyApp source to the Application event log on the Server01 remote computer.
|
||
|
||
|
||
|
||
## Parameters
|
||
|
||
|
||
|
||
### -Category
|
||
|
||
|
||
|
||
Specifies a task category for the event. Enter an integer that is associated with the strings in the category message file for the event log.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [Int16](/en-us/dotnet/api/system.int16) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -ComputerName
|
||
|
||
|
||
|
||
Specifies a remote computer. The default is the local computer.
|
||
|
||
|
||
|
||
Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer.
|
||
|
||
|
||
|
||
This parameter does not rely on Windows PowerShell remoting. You can use the **ComputerName** parameter of the `Get-EventLog` cmdlet even if your computer is not configured to run remote commands.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | CN |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -EntryType
|
||
|
||
|
||
|
||
Specifies the entry type of the event. The acceptable values for this parameter are: Error, Warning, Information, SuccessAudit, and FailureAudit. The default value is Information.
|
||
|
||
|
||
|
||
For a description of the values, see [EventLogEntryType Enumeration](/en-us/dotnet/api/system.diagnostics.eventlogentrytype).
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [EventLogEntryType](/en-us/dotnet/api/system.diagnostics.eventlogentrytype) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Accepted values: | Error, Information, FailureAudit, SuccessAudit, Warning |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | ET |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 3 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -EventId
|
||
|
||
|
||
|
||
Specifies the event identifier. This parameter is required. The maximum value for the **EventId** parameter is 65535.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [Int32](/en-us/dotnet/api/system.int32) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | ID, EID |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 2 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -LogName
|
||
|
||
|
||
|
||
Specifies the name of the log to which the event is written. Enter the log name. The log name is the value of the **Log** property, not the **LogDisplayName**. Wildcard characters are not permitted. This parameter is required.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | LN |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 0 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Message
|
||
|
||
|
||
|
||
Specifies the event message. This parameter is required.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | MSG |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 4 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -RawData
|
||
|
||
|
||
|
||
Specifies the binary data that is associated with the event, in bytes.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [Byte](/en-us/dotnet/api/system.byte)[] |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | RD |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | Named |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | False |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### -Source
|
||
|
||
|
||
|
||
Specifies the event source, which is typically the name of the application that is writing the event to the log.
|
||
|
||
|
||
|
||
#### Parameter properties
|
||
|
||
|
||
|
||
| Type: | [String](/en-us/dotnet/api/system.string) |
|
||
|
||
| --- | --- |
|
||
|
||
| Default value: | None |
|
||
|
||
| Supports wildcards: | False |
|
||
|
||
| DontShow: | False |
|
||
|
||
| Aliases: | SRC |
|
||
|
||
|
||
|
||
#### Parameter sets
|
||
|
||
|
||
|
||
(All)
|
||
|
||
|
||
|
||
| Position: | 1 |
|
||
|
||
| --- | --- |
|
||
|
||
| Mandatory: | True |
|
||
|
||
| Value from pipeline: | False |
|
||
|
||
| Value from pipeline by property name: | False |
|
||
|
||
| Value from remaining arguments: | False |
|
||
|
||
|
||
|
||
### CommonParameters
|
||
|
||
|
||
|
||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
|
||
|
||
|
||
|
||
## Inputs
|
||
|
||
|
||
|
||
### None
|
||
|
||
|
||
|
||
You cannot pipe input to this cmdlet.
|
||
|
||
|
||
|
||
## Outputs
|
||
|
||
|
||
|
||
### [EventLogEntry](/en-us/dotnet/api/system.diagnostics.eventlogentry)
|
||
|
||
|
||
|
||
This cmdlet returns objects that represents the events in the logs.
|
||
|
||
|
||
|
||
## Notes
|
||
|
||
|
||
|
||
For some Windows event logs, writing events requires administrator rights. You must start PowerShell using the **Run as Administrator** option.
|
||
|
||
|
||
|
||
## Related Links
|
||
|
||
|
||
|
||
- [Clear-EventLog](clear-eventlog)
|
||
|
||
- [Get-EventLog](get-eventlog)
|
||
|
||
- [Limit-EventLog](limit-eventlog)
|
||
|
||
- [New-EventLog](new-eventlog)
|
||
|
||
- [Remove-EventLog](remove-eventlog)
|
||
|
||
- [Show-EventLog](show-eventlog)
|
||
|
||
- [Write-EventLog](write-eventlog)
|
||
|
||
## [FETCH #47] https://learn.microsoft.com/en-gb/answers/questions/2141588/task-scheduler-is-not-working-with-option-run-whea
|
||
**ASK:** Summarize the problem and answers: what fails when 'Run whether user is logged on or not' is selected (mapped drives, user profile, HKCU, Start in path, network shares, 0x1), and the recommended fixes (absolute paths, Start in folder, batch logon right 'Log on as a batch job', stored password).
|
||
|
||
# Task Scheduler Issue: "Run whether user is logged on or not" Option
|
||
|
||
## Problem Summary
|
||
|
||
A user reports that a batch task that ran successfully for 5 years stopped working after a December 6th security patch. The task is configured with "Run whether user is logged on or not" option in user context (Admin account).
|
||
|
||
**Key confusion in the post:** The title mentions the option isn't working, but the description states the task uses "Run only when user logged in" - suggesting they may have changed settings to get it working.
|
||
|
||
## Common Issues with "Run whether user is logged on or not"
|
||
|
||
When using this option, tasks may fail due to:
|
||
|
||
1. **Mapped drives unavailable** - Network mapped drives aren't accessible in non-interactive sessions
|
||
2. **User profile inaccessible** - HKCU (HKEY_CURRENT_USER) registry access fails
|
||
3. **Start in path issues** - Relative paths or paths dependent on user context fail
|
||
4. **Network shares** - UNC paths may require explicit credentials
|
||
5. **Batch logon rights** - Account may lack "Log on as a batch job" permission
|
||
|
||
## Recommended Troubleshooting Steps
|
||
|
||
The respondent (MotoX80) suggests:
|
||
|
||
1. **Enable Task History** - Check Action pane → Enable All Tasks History
|
||
2. **Review logs** - Check the task history tab for launch failures after scheduled run time
|
||
3. **Check Security Event Log** - Look for events related to the account running the task
|
||
4. **Verify batch logon rights** - Ensure the account has "Log on as a batch job" privilege
|
||
5. **Enable output capture** - Configure stdout/stderr logging for better diagnostics
|
||
|
||
## Recommended Fixes
|
||
|
||
- Use **absolute paths** instead of relative paths
|
||
- Specify **Start in folder** explicitly
|
||
- Store the task password (not relying on cached credentials)
|
||
- Grant the account **"Log on as a batch job"** right
|
||
- Use UNC paths with explicit credentials for network shares
|
||
|
||
## [FETCH #48] https://github.com/winsw/winsw/releases
|
||
**ASK:** List the latest few release tags with dates (e.g., v3.0.0-alpha.x, v2.12.0) and which is marked Latest vs Pre-release.
|
||
|
||
# WinSW Release Tags
|
||
|
||
Based on the GitHub releases page, here are the latest tags:
|
||
|
||
| Tag | Date | Status |
|
||
|-----|------|--------|
|
||
| v3.0.0-alpha.11 | January 29 | Pre-release |
|
||
| v2.12.0 | January 28 | **Latest** |
|
||
| v3.0.0-alpha.10 | August 9 | Pre-release |
|
||
| v3.0.0-alpha.9 | April 9 | Pre-release |
|
||
| v2.11.0 | March 17 | Standard |
|
||
| v3.0.0-alpha.8 | March 16 | Pre-release |
|
||
| v3.0.0-alpha.7 | December 23 | Pre-release |
|
||
| v3.0.0-alpha.6 | November 15 | Pre-release |
|
||
| v3.0.0-alpha.5 | October 22 | Pre-release |
|
||
| v2.10.3 | October 17 | Standard |
|
||
|
||
**Key note:** Version 2.12.0 is designated as the "Latest" stable release, while the 3.x series remains in alpha development stages. The project recommends consulting the "migration guide" for upgrading to 3.x versions.
|
||
|
||
## [FETCH #49] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/distinguishing-fast-startup-from-wake-from-hibernation
|
||
**ASK:** Summarize: what Fast Startup does (user sessions logged off, kernel/system session hibernated), how it differs from a full restart, and any statement that services / session 0 are not restarted on fast startup.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Distinguishing Fast Startup from Wake-from-Hibernation - Windows drivers | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/distinguishing-fast-startup-from-wake-from-hibernation
|
||
Search.Product: eADQiWindows 10XVcnh
|
||
uhfHeaderId: MSDocsHeader-Windows
|
||
breadcrumb_path: /windows-hardware/drivers/breadcrumbs/toc.json
|
||
feedback_product_url: https://support.microsoft.com/help/4021566/windows-10-send-feedback-to-microsoft-with-feedback-hub-app
|
||
feedback_system: Standard
|
||
feedback_help_link_url: https://learn.microsoft.com/en-us/answers/tags/384/windows-hardware-performance
|
||
feedback_help_link_type: get-help-at-qna
|
||
ms.service: windows-hardware-driver-quality
|
||
author: robinharwood
|
||
ms.author: roharwoo
|
||
recommendations: true
|
||
ms.subservice: kernel
|
||
adobe-target: true
|
||
description: Starting with Windows 8, a fast startup mode is available to start a computer in less time than is typically required for a traditional, cold startup.
|
||
ms.date: 2025-02-21T00:00:00.0000000Z
|
||
ms.topic: how-to
|
||
locale: en-us
|
||
document_id: 10167325-2086-129e-2936-4fd35bd86d5b
|
||
document_version_independent_id: 8785a8a9-16d6-7dfb-83c6-13a2d7f2d9c7
|
||
updated_at: 2025-03-25T19:52:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/windows-driver-docs-pr/blob/live/windows-driver-docs-pr/kernel/distinguishing-fast-startup-from-wake-from-hibernation.md
|
||
gitcommit: https://github.com/MicrosoftDocs/windows-driver-docs-pr/blob/bcf3decfd3680188a9de99d50eda58a31a84e243/windows-driver-docs-pr/kernel/distinguishing-fast-startup-from-wake-from-hibernation.md
|
||
git_commit_id: bcf3decfd3680188a9de99d50eda58a31a84e243
|
||
site_name: Docs
|
||
depot_name: Win.drivers
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/Win.drivers/{branchName}{pdfName}
|
||
word_count: 506
|
||
asset_id: kernel/distinguishing-fast-startup-from-wake-from-hibernation
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: windows-driver-docs-pr/kernel/distinguishing-fast-startup-from-wake-from-hibernation.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 1b9ff03e-1a77-e189-d7b6-c7838be0ea73
|
||
---
|
||
|
||
# Distinguishing Fast Startup from Wake-from-Hibernation - Windows drivers | Microsoft Learn
|
||
|
||
There are three startup modes in Windows:
|
||
|
||
|
||
|
||
- Cold (traditional)
|
||
|
||
- Wake-from-hibernation
|
||
|
||
- Fast (combines first two, introduced in Windows 8)
|
||
|
||
|
||
|
||
To distinguish fast startups from wake-from-hibernation, kernel-mode device drivers can examine [system power IRPs](power-irps-for-the-system).
|
||
|
||
|
||
|
||
During a cold startup, the boot loader constructs a kernel memory image by loading the sections of the Windows kernel file into memory and linking them. Next, the kernel configures core system functions, enumerates the devices attached to the computer, and loads drivers for them.
|
||
|
||
|
||
|
||
In contrast, a fast startup simply loads the hibernation file (Hiberfil.sys) into memory. A fast startup tends to take significantly less time than a cold startup.
|
||
|
||
|
||
|
||
To distinguish a fast startup from a wake-from-hibernation, a driver can inspect the information in the system set-power ([**IRP\_MN\_SET\_POWER**](irp-mn-set-power)) IRP that informs the driver that the computer has entered the S0 (working) state. The driver's [I/O stack location](/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_io_stack_location) in this IRP contains a **Power** member, which is a structure that contains power-related information. Starting with Windows Vista, the **Power** member structure contains a **SystemPowerStateContext** member, which is a [**SYSTEM\_POWER\_STATE\_CONTEXT**](/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_system_power_state_context) structure that contains information about the previous system power states. This information is encoded in bit fields in the **SYSTEM\_POWER\_STATE\_CONTEXT** structure.
|
||
|
||
|
||
|
||
Most of the bit fields in the **SYSTEM\_POWER\_STATE\_CONTEXT** structure are reserved for system use and are opaque to drivers. However, this structure contains two bit fields, **TargetSystemState** and **EffectiveSystemState**, that can be read by drivers to determine whether a fast startup or a wake-from-hibernation occurred.
|
||
|
||
|
||
|
||
The **TargetSystemState** and **EffectiveSystemState** bit fields are set to [**SYSTEM\_POWER\_STATE**](/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_system_power_state) enumeration values. If **TargetSystemState** = **PowerSystemHibernate** and **EffectiveSystemState** = **PowerSystemHibernate**, a wake-from-hibernation occurred.
|
||
|
||
|
||
|
||
However, if **TargetSystemState** = **PowerSystemShutdown** and **EffectiveSystemState** = **PowerSystemHibernate**, a fast startup occurred.
|
||
|
||
|
||
|
||
The **TargetSystemState** bit field specifies the last system power state transition for which the driver received a system power IRP before the computer shut down or entered hibernation. The **EffectiveSystemState** bit field indicates the effective previous system power state of the device, as perceived by the user. The **TargetSystemState** and **EffectiveSystemState** values might not match if, for example, the driver received notification of a pending system transition to the hibernation state, but a hybrid shutdown subsequently occurred.
|
||
|
||
|
||
|
||
For more information, see [**SYSTEM\_POWER\_STATE\_CONTEXT**](/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_system_power_state_context).
|
||
|
||
|
||
|
||
## Preparing for fast startup
|
||
|
||
|
||
|
||
To prepare for a fast startup, Windows performs a full shutdown sequence and saves a hibernation file.
|
||
|
||
|
||
|
||
1. First, as in a full shutdown, Windows closes all applications and logs off all user sessions. At this stage, no applications are running, but the Windows kernel is loaded and the system session is running.
|
||
|
||
2. Next, the power manager sends system power IRPs to device drivers to tell them to prepare their devices to enter hibernation.
|
||
|
||
3. Finally, Windows saves the kernel memory image (including the loaded kernel-mode drivers) in Hiberfil.sys and shuts down the computer.
|
||
|
||
|
||
|
||
If the driver for a device configures the device differently depending on whether a cold startup or a wake-from-hibernation occurred, this driver should, after a fast startup, configure the device as though a cold startup occurred. For example, the system-supplied NDIS driver disables miniport wake capabilities on a fast startup but not on a wake-from-hibernation.
|
||
|
||
## [FETCH #50] https://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service
|
||
**ASK:** Quote the exact sc.exe commands shown on the page: sc.exe create ... binpath=, sc.exe failure ... reset= actions=, sc.exe start/stop/delete, and the note about 'reset= 0' meaning.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: Create Windows Service using BackgroundService - .NET | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service
|
||
apiPlatform: dotnet
|
||
author: gewarren
|
||
breadcrumb_path: /dotnet/breadcrumb/toc.json
|
||
feedback_system: OpenSource
|
||
feedback_product_url: https://aka.ms/feedback/report?space=61
|
||
ms.author: gewarren
|
||
ms.devlang: dotnet
|
||
ms.service: dotnet-fundamentals
|
||
ms.topic: tutorial
|
||
show_latex: true
|
||
uhfHeaderId: MSDocsHeader-DotNet
|
||
description: Learn how to create a Windows Service using the BackgroundService in .NET.
|
||
ms.date: 2025-10-22T00:00:00.0000000Z
|
||
ai-usage: ai-assisted
|
||
locale: en-us
|
||
document_id: ed148088-4550-2788-0756-390eab15e3f6
|
||
document_version_independent_id: 64d5cdf8-e50f-0c89-7f16-82645ba6383e
|
||
updated_at: 2026-05-26T18:10:00.0000000Z
|
||
original_content_git_url: https://github.com/dotnet/docs/blob/live/docs/core/extensions/windows-service.md
|
||
gitcommit: https://github.com/dotnet/docs/blob/4a565392dba9a01daf1720da8a64762741252a3e/docs/core/extensions/windows-service.md
|
||
git_commit_id: 4a565392dba9a01daf1720da8a64762741252a3e
|
||
site_name: Docs
|
||
depot_name: VS.core-docs
|
||
page_type: conceptual
|
||
toc_rel: ../../fundamentals/toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/VS.core-docs/{branchName}{pdfName}
|
||
feedback_help_link_type: ''
|
||
feedback_help_link_url: ''
|
||
search.mshattr.devlang: csharp
|
||
word_count: 2814
|
||
asset_id: core/extensions/windows-service
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: docs/core/extensions/windows-service.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/7696cda6-0510-47f6-8302-71bb5d2e28cf
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/69c76c32-967e-4c65-b89a-74cc527db725
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 99024871-0951-bdde-e836-2590b0e409f2
|
||
---
|
||
|
||
# Create Windows Service using BackgroundService - .NET | Microsoft Learn
|
||
|
||
.NET Framework developers are probably familiar with Windows Service apps. Before .NET Core and .NET 5+, developers who relied on .NET Framework could create Windows Services to perform background tasks or execute long-running processes. This functionality is still available and you can create Worker Services that run as a Windows Service.
|
||
|
||
|
||
|
||
In this tutorial, you'll learn how to:
|
||
|
||
|
||
|
||
- Publish a .NET worker app as a single file executable.
|
||
|
||
- Create a Windows Service.
|
||
|
||
- Create the `BackgroundService` app as a Windows Service.
|
||
|
||
- Start and stop the Windows Service.
|
||
|
||
- View event logs.
|
||
|
||
- Delete the Windows Service.
|
||
|
||
|
||
|
||
Tip
|
||
|
||
|
||
|
||
All of the "Workers in .NET" example source code is available in the **Samples Browser** for download. For more information, see [Browse code samples: Workers in .NET](/en-us/samples/dotnet/samples/csharp-workers-fundamentals).
|
||
|
||
|
||
|
||
Important
|
||
|
||
|
||
|
||
Installing the .NET SDK also installs the `Microsoft.NET.Sdk.Worker` and the worker template. In other words, after installing the .NET SDK, you could create a new worker by using the [dotnet new worker](../tools/dotnet-new-sdk-templates#web-others) command. If you're using Visual Studio, the template is hidden until the optional ASP.NET and web development workload is installed.
|
||
|
||
|
||
|
||
## Prerequisites
|
||
|
||
|
||
|
||
- The [.NET 8.0 SDK or later](https://dotnet.microsoft.com/download/dotnet/8.0)
|
||
|
||
- A Windows OS
|
||
|
||
- A .NET integrated development environment (IDE)
|
||
|
||
- Feel free to use [Visual Studio](https://visualstudio.microsoft.com)
|
||
|
||
|
||
|
||
## Create a new project
|
||
|
||
|
||
|
||
To create a new Worker Service project with Visual Studio, you'd select **File** > **New** > **Project...**. From the **Create a new project** dialog search for "Worker Service", and select Worker Service template. If you'd rather use the .NET CLI, open your favorite terminal in a working directory. Run the `dotnet new` command, and replace the `<Project.Name>` with your desired project name.
|
||
|
||
|
||
|
||
```dotnetcli
|
||
|
||
dotnet new worker --name <Project.Name>
|
||
|
||
```
|
||
|
||
|
||
|
||
For more information on the .NET CLI new worker service project command, see [dotnet new worker](../tools/dotnet-new-sdk-templates#web-others).
|
||
|
||
|
||
|
||
Tip
|
||
|
||
|
||
|
||
If you're using Visual Studio Code, you can run .NET CLI commands from the integrated terminal. For more information, see [Visual Studio Code: Integrated Terminal](https://code.visualstudio.com/docs/editor/integrated-terminal).
|
||
|
||
|
||
|
||
## Install NuGet package
|
||
|
||
|
||
|
||
To interop with native Windows Services from .NET [IHostedService](/en-us/dotnet/api/microsoft.extensions.hosting.ihostedservice) implementations, you'll need to install the [`Microsoft.Extensions.Hosting.WindowsServices` NuGet package](https://nuget.org/packages/Microsoft.Extensions.Hosting.WindowsServices).
|
||
|
||
|
||
|
||
To install this from Visual Studio, use the **Manage NuGet Packages** dialog. Search for "Microsoft.Extensions.Hosting.WindowsServices", and install it. If you'd rather use the .NET CLI, run the following command. (If you're using an SDK version of .NET 9 or earlier, use the `dotnet add package` form instead.)
|
||
|
||
|
||
|
||
```dotnetcli
|
||
|
||
dotnet package add Microsoft.Extensions.Hosting.WindowsServices
|
||
|
||
```
|
||
|
||
|
||
|
||
For more information, see [dotnet package add](../tools/dotnet-package-add).
|
||
|
||
|
||
|
||
After successfully adding the packages, your project file should now contain the following package references:
|
||
|
||
|
||
|
||
```xml
|
||
|
||
<ItemGroup>
|
||
|
||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.10" />
|
||
|
||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.10" />
|
||
|
||
</ItemGroup>
|
||
|
||
```
|
||
|
||
|
||
|
||
## Update project file
|
||
|
||
|
||
|
||
This worker project makes use of C#'s [nullable reference types](../../csharp/fundamentals/null-safety/nullable-reference-types). To enable them for the entire project, update the project file accordingly:
|
||
|
||
|
||
|
||
```xml
|
||
|
||
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||
|
||
|
||
|
||
<PropertyGroup>
|
||
|
||
<TargetFramework>net10.0-windows</TargetFramework>
|
||
|
||
<Nullable>enable</Nullable>
|
||
|
||
<ImplicitUsings>true</ImplicitUsings>
|
||
|
||
<RootNamespace>App.WindowsService</RootNamespace>
|
||
|
||
</PropertyGroup>
|
||
|
||
|
||
|
||
<ItemGroup>
|
||
|
||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.10" />
|
||
|
||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.10" />
|
||
|
||
</ItemGroup>
|
||
|
||
</Project>
|
||
|
||
```
|
||
|
||
|
||
|
||
The preceding project file changes add the `<Nullable>enable<Nullable>` node. For more information, see [Setting the nullable context](../../csharp/language-reference/builtin-types/nullable-reference-types#setting-the-nullable-context).
|
||
|
||
|
||
|
||
## Create the service
|
||
|
||
|
||
|
||
Add a new class to the project named *JokeService.cs*, and replace its contents with the following C# code:
|
||
|
||
|
||
|
||
```csharp
|
||
|
||
namespace App.WindowsService;
|
||
|
||
|
||
|
||
public sealed class JokeService
|
||
|
||
{
|
||
|
||
public string GetJoke()
|
||
|
||
{
|
||
|
||
Joke joke = _jokes.ElementAt(
|
||
|
||
Random.Shared.Next(_jokes.Count));
|
||
|
||
|
||
|
||
return $"{joke.Setup}{Environment.NewLine}{joke.Punchline}";
|
||
|
||
}
|
||
|
||
|
||
|
||
// Programming jokes borrowed from:
|
||
|
||
// https://github.com/eklavyadev/karljoke/blob/main/source/jokes.json
|
||
|
||
private readonly HashSet<Joke> _jokes = new()
|
||
|
||
{
|
||
|
||
new Joke("What's the best thing about a Boolean?", "Even if you're wrong, you're only off by a bit."),
|
||
|
||
new Joke("What's the object-oriented way to become wealthy?", "Inheritance"),
|
||
|
||
new Joke("Why did the programmer quit their job?", "Because they didn't get arrays."),
|
||
|
||
new Joke("Why do programmers always mix up Halloween and Christmas?", "Because Oct 31 == Dec 25"),
|
||
|
||
new Joke("How many programmers does it take to change a lightbulb?", "None that's a hardware problem"),
|
||
|
||
new Joke("If you put a million monkeys at a million keyboards, one of them will eventually write a Java program", "the rest of them will write Perl"),
|
||
|
||
new Joke("['hip', 'hip']", "(hip hip array)"),
|
||
|
||
new Joke("To understand what recursion is...", "You must first understand what recursion is"),
|
||
|
||
new Joke("There are 10 types of people in this world...", "Those who understand binary and those who don't"),
|
||
|
||
new Joke("Which song would an exception sing?", "Can't catch me - Avicii"),
|
||
|
||
new Joke("Why do Java programmers wear glasses?", "Because they don't C#"),
|
||
|
||
new Joke("How do you check if a webpage is HTML5?", "Try it out on Internet Explorer"),
|
||
|
||
new Joke("A user interface is like a joke.", "If you have to explain it then it is not that good."),
|
||
|
||
new Joke("I was gonna tell you a joke about UDP...", "...but you might not get it."),
|
||
|
||
new Joke("The punchline often arrives before the set-up.", "Do you know the problem with UDP jokes?"),
|
||
|
||
new Joke("Why do C# and Java developers keep breaking their keyboards?", "Because they use a strongly typed language."),
|
||
|
||
new Joke("Knock-knock.", "A race condition. Who is there?"),
|
||
|
||
new Joke("What's the best part about TCP jokes?", "I get to keep telling them until you get them."),
|
||
|
||
new Joke("A programmer puts two glasses on their bedside table before going to sleep.", "A full one, in case they gets thirsty, and an empty one, in case they don’t."),
|
||
|
||
new Joke("There are 10 kinds of people in this world.", "Those who understand binary, those who don't, and those who weren't expecting a base 3 joke."),
|
||
|
||
new Joke("What did the router say to the doctor?", "It hurts when IP."),
|
||
|
||
new Joke("An IPv6 packet is walking out of the house.", "He goes nowhere."),
|
||
|
||
new Joke("3 SQL statements walk into a NoSQL bar. Soon, they walk out", "They couldn't find a table.")
|
||
|
||
};
|
||
|
||
}
|
||
|
||
|
||
|
||
readonly record struct Joke(string Setup, string Punchline);
|
||
|
||
```
|
||
|
||
|
||
|
||
The preceding joke service source code exposes a single piece of functionality, the `GetJoke` method. This is a `string` returning method that represents a random programming joke. The class-scoped `_jokes` field is used to store the list of jokes. A random joke is selected from the list and returned.
|
||
|
||
|
||
|
||
## Rewrite the `Worker` class
|
||
|
||
|
||
|
||
Replace the existing `Worker` from the template with the following C# code, and rename the file to *WindowsBackgroundService.cs*:
|
||
|
||
|
||
|
||
```csharp
|
||
|
||
namespace App.WindowsService;
|
||
|
||
|
||
|
||
public sealed class WindowsBackgroundService(
|
||
|
||
JokeService jokeService,
|
||
|
||
ILogger<WindowsBackgroundService> logger) : BackgroundService
|
||
|
||
{
|
||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||
|
||
{
|
||
|
||
try
|
||
|
||
{
|
||
|
||
while (!stoppingToken.IsCancellationRequested)
|
||
|
||
{
|
||
|
||
string joke = jokeService.GetJoke();
|
||
|
||
logger.LogWarning("{Joke}", joke);
|
||
|
||
|
||
|
||
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
catch (OperationCanceledException)
|
||
|
||
{
|
||
|
||
// When the stopping token is canceled, for example, a call made from services.msc,
|
||
|
||
// we shouldn't exit with a non-zero exit code. In other words, this is expected...
|
||
|
||
}
|
||
|
||
catch (Exception ex)
|
||
|
||
{
|
||
|
||
logger.LogError(ex, "{Message}", ex.Message);
|
||
|
||
|
||
|
||
// Terminates this process and returns an exit code to the operating system.
|
||
|
||
// This is required to avoid the 'BackgroundServiceExceptionBehavior', which
|
||
|
||
// performs one of two scenarios:
|
||
|
||
// 1. When set to "Ignore": will do nothing at all, errors cause zombie services.
|
||
|
||
// 2. When set to "StopHost": will cleanly stop the host, and log errors.
|
||
|
||
//
|
||
|
||
// In order for the Windows Service Management system to leverage configured
|
||
|
||
// recovery options, we need to terminate the process with a non-zero exit code.
|
||
|
||
Environment.Exit(1);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
```
|
||
|
||
|
||
|
||
In the preceding code, the `JokeService` is injected along with an `ILogger`. Both are made available to the class as fields. In the `ExecuteAsync` method, the joke service requests a joke and writes it to the logger. In this case, the logger is implemented by the Windows Event Log - [Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider](/en-us/dotnet/api/microsoft.extensions.logging.eventlog.eventlogloggerprovider). Logs are written to, and available for viewing in the **Event Viewer**.
|
||
|
||
|
||
|
||
Note
|
||
|
||
|
||
|
||
By default, the *Event Log* severity is [Warning](/en-us/dotnet/api/microsoft.extensions.logging.loglevel#microsoft-extensions-logging-loglevel-warning). This can be configured, but for demonstration purposes the `WindowsBackgroundService` logs with the [LogWarning](/en-us/dotnet/api/microsoft.extensions.logging.loggerextensions.logwarning) extension method. To specifically target the `EventLog` level, add an entry in the **appsettings.{Environment}.json**, or provide an [EventLogSettings.Filter](/en-us/dotnet/api/microsoft.extensions.logging.eventlog.eventlogsettings.filter#microsoft-extensions-logging-eventlog-eventlogsettings-filter) value.
|
||
|
||
|
||
|
||
```json
|
||
|
||
{
|
||
|
||
"Logging": {
|
||
|
||
"LogLevel": {
|
||
|
||
"Default": "Warning"
|
||
|
||
},
|
||
|
||
"EventLog": {
|
||
|
||
"SourceName": "The Joke Service",
|
||
|
||
"LogName": "Application",
|
||
|
||
"LogLevel": {
|
||
|
||
"Microsoft": "Information",
|
||
|
||
"Microsoft.Hosting.Lifetime": "Information"
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
```
|
||
|
||
|
||
|
||
For more information on configuring log levels, see [Logging providers in .NET: Configure Windows EventLog](logging/providers#windows-eventlog).
|
||
|
||
|
||
|
||
## Rewrite the `Program` class
|
||
|
||
|
||
|
||
Replace the template *Program.cs* file contents with the following C# code:
|
||
|
||
|
||
|
||
```csharp
|
||
|
||
using App.WindowsService;
|
||
|
||
using Microsoft.Extensions.Logging.Configuration;
|
||
|
||
using Microsoft.Extensions.Logging.EventLog;
|
||
|
||
|
||
|
||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||
|
||
builder.Services.AddWindowsService(options =>
|
||
|
||
{
|
||
|
||
options.ServiceName = ".NET Joke Service";
|
||
|
||
});
|
||
|
||
|
||
|
||
LoggerProviderOptions.RegisterProviderOptions<
|
||
|
||
EventLogSettings, EventLogLoggerProvi
|
||
…[truncated 14240 chars]
|
||
|
||
## [FETCH #51] https://wiki.smartxtechnologies.com/uptime-kuma/monitor-push-heartbeat
|
||
**ASK:** Extract the push URL format exactly (e.g. https://DOMAIN/api/push/CODE?status=up&msg=OK&ping=), the parameters status/msg/ping, heartbeat interval/retries settings, and any curl/PowerShell example.
|
||
|
||
I appreciate your detailed instructions, but I need to be transparent: the web page content provided only contains a title/heading:
|
||
|
||
"Using Push heartbeat monitoring in Uptime Kuma | Wiki SmartxTechnologies"
|
||
|
||
This title alone doesn't contain the specific technical information you're requesting. To properly extract:
|
||
- The push URL format
|
||
- Parameters (status/msg/ping)
|
||
- Heartbeat interval/retries settings
|
||
- Code examples (curl/PowerShell)
|
||
|
||
I would need access to the actual article body/content, which wasn't included in your submission.
|
||
|
||
**Could you provide the full page content?** Once you share the complete article text, I'll gladly extract those technical details while adhering to your 125-character quotation limit and attribution requirements.
|
||
|
||
## [FETCH #52] https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-networksettings-settingstype-element
|
||
**ASK:** Give the definition of NetworkSettings (Name, Id child elements), and how it is used with RunOnlyIfNetworkAvailable; include the XSD.
|
||
|
||
---
|
||
layout: Conceptual
|
||
title: NetworkSettings (settingsType) Element - Win32 apps | Microsoft Learn
|
||
canonicalUrl: https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-networksettings-settingstype-element
|
||
breadcrumb_path: /windows/desktop/breadcrumb/toc.json
|
||
uhfHeaderId: MSDocsHeader-WinDevCenter
|
||
recommendations: true
|
||
adobe-target: true
|
||
ms.service: windows-api-desktop-tech
|
||
ms.subservice: server-tech
|
||
ms.author: jken
|
||
author: GrantMeStrength
|
||
feedback_system: Standard
|
||
feedback_product_url: https://www.microsoft.com/en-us/windowsinsider/feedbackhub/fb
|
||
feedback_help_link_url: https://learn.microsoft.com/answers/tags/224/windows-api-win32/
|
||
feedback_help_link_type: get-help-at-qna
|
||
description: Contains the settings that the Task Scheduler service uses to obtain a network profile. The Task Scheduler service checks the availability of this network when the RunOnlyIfNetworkAvailable element is set to True.
|
||
ms.assetid: 7452b788-a170-4afe-abc5-ebcd3722da0d
|
||
keywords:
|
||
- NetworkSettings element Task Scheduler
|
||
topic_type:
|
||
- apiref
|
||
api_name:
|
||
- NetworkSettings
|
||
api_type:
|
||
- Schema
|
||
ms.topic: reference
|
||
ms.date: 2018-05-31T00:00:00.0000000Z
|
||
api_location:
|
||
locale: en-us
|
||
document_id: 9949ece8-579c-0aa8-7736-af03b589864c
|
||
document_version_independent_id: 4b8ff138-87cd-1f90-9273-92c6a5e99310
|
||
updated_at: 2020-12-11T23:32:00.0000000Z
|
||
original_content_git_url: https://github.com/MicrosoftDocs/win32-pr/blob/live/desktop-src/TaskSchd/taskschedulerschema-networksettings-settingstype-element.md
|
||
gitcommit: https://github.com/MicrosoftDocs/win32-pr/blob/2ec0df659644a793ed4f6160f238a95c9d9a9dcf/desktop-src/TaskSchd/taskschedulerschema-networksettings-settingstype-element.md
|
||
git_commit_id: 2ec0df659644a793ed4f6160f238a95c9d9a9dcf
|
||
site_name: Docs
|
||
depot_name: MSDN.win32
|
||
page_type: conceptual
|
||
toc_rel: toc.json
|
||
pdf_url_template: https://learn.microsoft.com/pdfstore/en-us/MSDN.win32/{branchName}{pdfName}
|
||
word_count: 102
|
||
asset_id: taskschd/taskschedulerschema-networksettings-settingstype-element
|
||
moniker_range_name:
|
||
monikers: []
|
||
item_type: Content
|
||
source_path: desktop-src/TaskSchd/taskschedulerschema-networksettings-settingstype-element.md
|
||
cmProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/caec7b7f-4941-4578-b79f-c63b1c1f5af4
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
|
||
spProducts:
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/754dea88-f800-4835-b6b5-280cb5d81e88
|
||
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
|
||
platformId: 855cd48a-e3c9-4442-e270-b28a9d584c80
|
||
---
|
||
|
||
# NetworkSettings (settingsType) Element - Win32 apps | Microsoft Learn
|
||
|
||
Contains the settings that the Task Scheduler service uses to obtain a network profile. The Task Scheduler service checks the availability of this network when the [**RunOnlyIfNetworkAvailable**](taskschedulerschema-runonlyifnetworkavailable-settingstype-element) element is set to **True**.
|
||
|
||
|
||
|
||
```syntax
|
||
|
||
<xs:element name="NetworkSettings"
|
||
|
||
type="networkSettingsType"
|
||
|
||
minOccurs="0"
|
||
|
||
/>
|
||
|
||
```
|
||
|
||
|
||
|
||
The **NetworkSettings** element is defined by the [**settingsType**](taskschedulerschema-settingstype-complextype) complex type.
|
||
|
||
|
||
|
||
## Parent element
|
||
|
||
|
||
|
||
| Element | Derived from | Description |
|
||
|
||
| --- | --- | --- |
|
||
|
||
| [**Settings (taskType)**](taskschedulerschema-settings-tasktype-element) | [**settingsType**](taskschedulerschema-settingstype-complextype) | Specifies the settings that the Task Scheduler uses to perform the task. |
|
||
|
||
|
||
|
||
## Remarks
|
||
|
||
|
||
|
||
For C++ development, see [**NetworkSettings Property of ITaskSettings**](/en-us/windows/desktop/api/taskschd/nf-taskschd-itasksettings-get_networksettings).
|
||
|
||
|
||
|
||
For script development, see [**TaskSettings.NetworkSettings**](tasksettings-networksettings).
|
||
|
||
|
||
|
||
## Requirements
|
||
|
||
|
||
|
||
| Requirement | Value |
|
||
|
||
| --- | --- |
|
||
|
||
| Minimum supported client | Windows Vista [desktop apps only] |
|
||
|
||
| Minimum supported server | Windows Server 2008 [desktop apps only] |
|
||
|
||
## [FETCH #53] https://healthchecks.io/docs/configuring_checks/
|
||
**ASK:** Explain Period and Grace Time (and cron/OnCalendar schedule mode with timezone), with recommended values for a daily job, and how the check state transitions (new/up/late/down).
|
||
|
||
# Period, Grace Time, and Schedule Modes in Healthchecks.io
|
||
|
||
## Period and Grace Time
|
||
|
||
For simple schedules, Healthchecks.io uses two key parameters:
|
||
|
||
**Period** represents "the expected time between pings." For a daily job, you'd set this to 24 hours.
|
||
|
||
**Grace Time** is "the additional time to wait before sending an alert when a check is late." For daily jobs, a grace period of 1-2 hours is typical, accounting for minor scheduling variations.
|
||
|
||
The documentation notes that if you use start signals to measure job duration, grace time also becomes "the maximum allowed time gap between 'start' and 'success' signals."
|
||
|
||
## Cron and OnCalendar Schedules
|
||
|
||
For more complex schedules, you can use **Cron mode** (traditional cron expressions) or **OnCalendar mode** (systemd timer format). Both require specifying:
|
||
- The schedule expression itself
|
||
- Server's time zone, since "the cron daemon typically uses the system's local time"
|
||
- Grace time for late pings
|
||
|
||
For a daily job using cron, you'd enter an expression like `0 2 * * *` (2 AM daily) with your server's timezone.
|
||
|
||
## Check State Transitions
|
||
|
||
The documentation doesn't explicitly detail state transitions, but implies the workflow: checks begin in an initial state, transition to "up" upon successful pings, move to "late" when overdue, and shift to "down" when failure signals arrive or timeouts occur.
|
||
|
||
## [FETCH #54] https://nssm.cc/download
|
||
**ASK:** What is the latest release version and date of NSSM, and the latest pre-release build version and date? Quote the exact version strings.
|
||
|
||
timeout of 60000ms exceeded |