SchTasks — управление планировщиком заданий из командной строки Windows.
    Для планирования и автоматического выполнения заданий в среде Windows предусмотрено стандартное программное средство Планировщик заданий , который обеспечивает выполнение заранее подготовленных задач в определенное время, или при возникновении определенных событий, однократно или с периодичностью, в контексте системных или пользовательских учетных записей. Другими словами, с использованием Планировщика заданий можно по расписанию, или при возникновении определенного события, выполнить заранее подготовленные действия, например, проверить наличие обновлений, синхронизировать часы по серверу времени при входе в систему любого пользователя, выключить или перезагрузить компьютер, создать точку восстановления системы и т.п. Начиная с Windows Vista, Планировщик заданий стал основным инструментом обслуживания системы, без которого невозможно ее нормальное функционирование. Для управлениями запланированными задачами в среде графического интерфейса пользователя может использоваться консоль управления MMC ( Microsoft Management Console ) с модулем taskschd.msc или утилита командной строки Schtask.exe
Утилита schtasks.exe является стандартным средством управления планировщиком и позволяет создавать, удалять, изменять и опрашивать запланированные задачи на локальном или удаленном компьютере.
Формат командной строки SchTask:
SCHTASKS /параметр [аргументы]
Справку по отдельным параметрам команды можно получить используя:
SCHTASKS /Run /? — подсказка по использованию /Run
SCHTASKS /End /? — подсказка по использованию /End
schtasks commands
Schedules commands and programs to run periodically or at a specific time, adds and removes tasks from the schedule, starts and stops tasks on demand, and displays and changes scheduled tasks.
The schtasks.exe tool performs the same operations as Scheduled Tasks in Control Panel. You can use these tools together and interchangeably.
Required permissions
To schedule, view, and change all tasks on the local computer, you must be a member of the Administrators group.
To schedule, view, and change all tasks on the remote computer, you must be a member of the Administrators group on the remote computer, or you must use the /u parameter to provide the credentials of an Administrator of the remote computer.
You can use the /u parameter in a /create or /change operation if the local and remote computers are in the same domain, or if the local computer is in a domain that the remote computer domain trusts. Otherwise, the remote computer can’t authenticate the user account specified, and it can’t verify that the account is a member of the Administrators group.
The task you plan to run must have the appropriate permission; these permissions vary by task. By default, tasks run with the permissions of the current user of the local computer, or with the permissions of the user specified by the /u parameter, if one is included. o run a task with permissions of a different user account or with system permissions, use the /ru parameter.
Run task manager command line
We can open task manager by running the command taskmgr from command prompt.
Note that this command launches the task manager GUI. It does not provide task manager functionality in command prompt(CLI). In case if you are looking for some command line equivalent of task manager then tasklist is the right command for you.
Image Name PID Session Name Session# Mem Usage
========================= ====== ================ ======== ============
System Idle Process 0 Console 0 28 K
System 4 Console 0 248 K
smss.exe 1292 Console 0 428 K
csrss.exe 1572 Console 0 8,824 K
winlogon.exe 1600 Console 0 8,672 K
services.exe 1644 Console 0 5,300 K
lsass.exe 1656 Console 0 2,332 K
ibmpmsvc.exe 1840 Console 0 1,660 K
svchost.exe 1872 Console 0 5,652 K
svchost.exe 1920 Console 0 5,460 K
svchost.exe 292 Console 0 33,208 K
S24EvMon.exe 520 Console 0 15,504 K
svchost.exe 688 Console 0 4,084 K
svchost.exe 808 Console 0 4,296 K
spoolsv.exe 1236 Console 0 7,432 K
TPHKSVC.exe 1424 Console 0 4,396 K
svchost.exe 1476 Console 0 3,532 K
CcmExec.exe 1516 Console 0 17,036 K
cvpnd.exe 1660 Console 0 5,532 K
tpnumlk.exe 1956 Console 0 2,896 K
DOZESVC.EXE 2028 Console 0 1,192 K
EvtEng.exe 192 Console 0 19,256 K
PresentationFontCache.exe 320 Console 0 7,632 K
iPassPeriodicUpdateServic 432 Console 0 4,620 K
iviRegMgr.exe 508 Console 0 2,460 K
cammute.exe 360 Console 0 3,252 K
micmute.exe 652 Console 0 2,164 K
LMS.exe 680 Console 0 4,756 K
FrameworkService.exe 744 Console 0 11,204 K
mcshield.exe 932 Console 0 174,120 K
Below are some Questions asked by blog readers about taskmgr command.
How about some /switches to start in a particular tab?
unfortunately there’s no such switch with taskmgr command..It always opens with the tab that was active when taskmgr was closed last time…
Thanks for that…How about open Windows 7 Task Manager with “show process’ for all users” active?
That’s also not possible from command line as taskmgr.exe does not accept any kind of parameters. You may try tasklist command which is a non-gui equivalent of taskmgr.
Hi – the info above does close off what might have been a fruitless search but …
When I click the “Show processes from all users” button, I get the UAC panel and it shows Program Location as:
“C:\Windows\System32\Taskmgr.exe” /1
What’s that about (the “/1” I mean).
Thanks,
Brian Howe
Most programs do accept parameters even if they don’t do anything with them :p
It’s used (or was used) internally by Windows to determine how the taskmgr was started. (Though only the devs know why!)
Taskmgr.exe /n where n =
1 – ‘Show processes from all users’ button clicked in a non-elevated Task Manager .
2 – Ctrl+Shift+Esc.
3 – Ctrl+Alt+Del, click Start Task Manager.
4 – Right-click taskbar, click Start Task Manager.
It was probably a dev debug tool that is likely ignored in released versions and certainly doesn’t seem to make any difference.
Also, as ‘someone’ already said, (changing a single word!) ALL programs accept parameters but it’s up to them what they do with them.
Windows commands
All supported versions of Windows (server and client) have a set of Win32 console commands built in.
This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Prerequisites
The information that is contained in this topic applies to:
- Windows Server 2019
- Windows Server (Semi-Annual Channel)
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2
- Windows Server 2008
- Windows 10
- Windows 8.1
Command shell overview
The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
You can also download and install PowerShell Core, the open source version of PowerShell.
Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.
To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Command-line reference A-Z
To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
Schedule tasks from command line
‘Schedule tasks‘ is a GUI application using which we can schedule tasks, There is an equivalent utility which provides the same functionality but with the advantage that it can be used from windows command line. This command is Schtasks. This is an in-built windows command supported by XP, Vista and Windows 7. Let’s see the syntax of this command with the help of few examples.
How to schedule a task ?
If you are logged into the same computer where you want to run the scheduled task, then you can use the below command to create the task.
Now let’s see few examples.
Example 1: Schedule disk defragmentation on every Saturday at 10AM. User credentials are administrator/password.
If the specified username and password are correct, then you would get the below message when you run the above command.
If the credentials are not correct, you may get a warning like below.
If there exists a scheduled task with the same name then the error would be:
If you need to use a domain user account to run the task you can specify domainname\username with /RU option.
How to get the list of scheduled tasks?
Just run Schtasks command and you can see the list of scheduled commands.
If you want complete details about each of the tasks you can run the command ‘Schtasks /query /v
DeleteВ a scheduled task
We can delete a schedule task using ‘schtasks /delete /TN task_name‘ command.В For example, to delete the task we created in the example 1 we can run the below command.
Delete all the scheduled tasks
You can run the below command to delete all the scheduled tasks.
Disable a scheduled task
There does not seem to be a way to disable a scheduled task from command line. We can delete the tasks as mentioned above.
ModifyВ a scheduled task:
We can change a scheduled task using ‘schtasks /change’ command. Run ‘schtasks /change /?’ for the syntax.
how to delete from the folder?
schtasks /delete /TN “Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser” /F
It is possibile to disable sheduled task. Here is an example:
schtasks /Change /TN “Microsoft\Windows\MUI\LPRemove” /Disable
How do you do it if the task is meant to be run on a DIFFERENT computer (like with the “connect to another computer”)? Thank you! On cmd please.
I’m regarding to run a batch file by a schedule task.
This script is running chrome with a specific url.
The problem is that I must choose some credential in my command line like this :
schtasks /create /sc once /tn Video_XP /tr “\\myserver\myscript.bat” /u contoso\admin /p mypassword /st 12:25:00
The problem is that the task is running with an other account than the login one.
If I replace /u by %username% i’m not able to specify the passord and the task will stuck in background requesting password.
Please tell how can I know whether a task is Enabled/Disabled using CMD queries
Please provide a Example supporting your answer.
what to add in cmd for sidebar execute properties, setting,
for this two things:
if the task fails, restart every: 30 minutes
also deselect stop the last if it runs longer den
Can I get the command to enable “Run whether user is logged in or not” option while scheduling task from command line.
Thanks in advance
Hello everybody!
I was forced to use win10 –
lot’s of automatic pop ups, reminders and other annoying stuff
called “features”. However:
My company is constructing high-level measurement devices.
(i’m doing electronics)
our win-develloper just committed suicide and i’m left with the crap…
(just kidding)
Please help me!
A pop up that wanted to update or install language-support popped up
and tried to connect to www to do some updates – Why?! The sys was running fine!
Since our devices are ment to work headless but only with a remote-access,
there will be no connection to www ever… So:
Q1) how to get win10 a bit more www-independent?
Back to the pop-ups: As a source of evel, i identified schtasks…
I don’t consider it smart, to have a let’s tidy-up-the harddrive-task starting in the bg,
or debugging when our customer just wants to shut down the system and is forced to wait.
So, what will be damaged (especially concerning wifi) when i just do
schtask /TN * /delete?
Thanks a lot for your answers!
(Sorry for my upset state…)
indigo
schtasks /Create /tn “mytask” /sc MINUTE /mo 1 /ru “myuser” /rp “mypassword” /tr “C:\Windows\System32\calc.exe”
this command does not run calculater.
Any help in this?
schtasks /Create /tn “mytask” /sc MINUTE /mo 1 /tr “C:\Windows\System32\calc.exe”
i guess you can run calc as a dif user, but no need to if youre just trying to add something. otherwise your syntax was incorrect and idk what your username and password were.
and you will want to run this after you get the above correct unless you want to see the calc open up every minute… 😉