大网数据广告活动
Windows排障命令

schtasks query

· 52CE 我爱测

Reference article for the schtasks query command, which lists all the tasks scheduled to run on the computer.

Lists all the tasks scheduled to run on the computer.

Syntax

schtasks [/query] [/fo {TABLE | LIST | CSV}] [/nh] [/v] [/s <computer> [/u [<domain>\]<user> [/p <password>]]] [/tn <taskname>] [/xml] [/hresult]

Parameters

Parameter Description
/query Optionally, specifies the name of the operation. Using this query without any parameters performs a query of all tasks on the system.
/fo <format> Specifies the output format. The valid values are TABLE, LIST, or CSV.
/nh Removes column headings from the table display. This parameter is valid with the TABLE or CSV output formats.
/v Adds the advanced properties of the task to the display. This parameter is valid with the LIST or CSV output formats.
/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. By default, the command runs with the permissions of the current user of the local computer. The specified user account must be a member of the Administrators group on the remote computer. The /u and /p parameters are valid only when you use /s.
/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.
/tn <taskname> Queries a specific task by path and name. If /tn is used, <taskname> cannot be blank. Assumes from root directory "\" folder by default (thus \ is omittable if the task is located in the root directory). Does not accept wildcards. Use quotation marks to enclose names that include spaces.
/xml Outputs all task definitions on the system to XML format. If /tn is specified, outputs the specific task name to XML format. The full path and name must be used.
/hresult Specifies the process exit code to be in HRESULT format.
/? Displays help at the command prompt.

Examples

To list all tasks scheduled for the local computer, type:

schtasks
schtasks /query

These commands produce the same result and can be used interchangeably.

To request a detailed display of the tasks on the local computer,type:

schtasks /query /fo LIST /v

This command uses the /v parameter to request a detailed (verbose) display and the /fo LIST parameter to format the display as a list for easy reading. You can use this command to verify that a task you created has the intended recurrence pattern.

To request a list of tasks scheduled for a remote computer and to add the tasks to a comma-separated log file on the local computer, type:

schtasks /query /s Reskit16 /fo csv /nh >> \\svr01\data\tasklogs\p0102.csv

You can use this command format to collect and track tasks that are scheduled for multiple computers. This command uses the /s parameter to identify the remote computer, Reskit16, the /fo parameter to specify the format and the /nh parameter to suppress the column headings. The >> append symbol redirects the output to the task log, p0102.csv, on the local computer, Svr01. Because the command runs on the remote computer, the local computer path must be fully qualified.

To get information for the Office Subscription Maintenance task using the /tn parameter, which can also be viewed via Task Scheduler in the location \Microsoft\Office\ with the root directory "\" seen under the Task Scheduler Library folder, type:

schtasks /query /tn "\Microsoft\Office\Office Subscription Maintenance"

Related links

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 02/13/2024
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。