命令行中的任务计划程序 [英] Task Scheduler from command line

查看:90
本文介绍了命令行中的任务计划程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从命令行执行与此XML文件(直接从任务计划程序中导出)等效的操作.

I'm trying to do the equivalent of this (exported directly from task scheduler) xml file from command line.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2014-04-15T15:17:02.4785276</Date>
    <Author>~COMPUTER_NAME~\~USER_NAME~</Author>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Security"&gt;&lt;Select Path="Security"&gt;*[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and EventID=4625]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
      <ValueQueries>
        <Value name="IpAddress">Event/EventData/Data[@Name='IpAddress']</Value>
      </ValueQueries>
    </EventTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>~COMPUTER_NAME~\~USER_NAME~</UserId>
      <LogonType>Password</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>~Location_Of_Batch_Script~</Command>
      <Arguments>$(IpAddress)</Arguments>
    </Exec>
  </Actions>
</Task>

这有可能吗?

目标是在特定事件(4625-RD连接尝试失败)发生时,以管理员身份运行批处理脚本,该事件将管理传入的蛮力攻击.安装程序脚本需要此命令才能将其添加到任务计划程序中.

The goal is to have a batch script run as administrator when a specific event (4625 - Failed RD connection attempt) which will manage incoming brute force attacks. This command is needed for the installer script to add this to the task scheduler.

它需要以管理员身份运行,但是有没有办法使人们不输入用户名和密码(或者甚至不需要)?

It needs to be run as administrator, but is there a way to do that without making people put their username and password in (or is that not even needed)?

此外,大多数Windows版本都支持此.xml文件或命令行变体吗?它旨在用于Windows Server操作系统.

Also, Would this .xml file or the command line variant be supported across most versions of Windows? It is intended for use on Windows Server OS's.

推荐答案

如果键入schtasks /create /?,它将告诉您该怎么做.您需要在某个阶段输入密码.如果使用服务或系统帐户,则在创建时输入密码(如果不是高级管理员).

If you type schtasks /create /? it will tell you what to do. You'll need a password at some stage. If using service or System account you put the password in when creating (if not an elevated admin).

LocalService帐户 LocalService帐户是服务控制管理器使用的预定义本地帐户.安全子系统无法识别此帐户,因此您不能在对LookupAccountName函数的调用中指定其名称.它在本地计算机上具有最低权限,并在网络上显示匿名凭据.在所有语言环境中的帐户名称均为NT AUTHORITY \ LOCALSERVICE.此帐户没有密码.

LocalService Account The LocalService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and presents anonymous credentials on the network. The name of the account in all locales is NT AUTHORITY\LOCALSERVICE. This account does not have a password.

NetworkService帐户 NetworkService帐户是服务控制管理器使用的预定义本地帐户.安全子系统无法识别此帐户,因此您不能在对LookupAccountName函数的调用中指定其名称.它在本地计算机上具有最低特权,并且充当网络上的计算机.在所有语言环境中的帐户名称均为NT AUTHORITY \ NETWORK SERVICE.该帐户没有密码

NetworkService Account The NetworkService account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has minimum privileges on the local computer and acts as the computer on the network. The name of the account in all locales is NT AUTHORITY\NETWORK SERVICE. This account does not have a password

LocalSystem帐户 LocalSystem帐户是服务控制管理器使用的预定义本地帐户.安全子系统无法识别此帐户,因此您不能在对LookupAccountName函数的调用中指定其名称.它在本地计算机上具有广泛的特权,并且充当网络上的计算机.它的令牌包括NT AUTHORITY \ SYSTEM和BUILTIN \ Administrators SID.这些帐户可以访问大多数系统对象.在所有语言环境中的帐户名称均为.\ LocalSystem.也可以使用名称LocalSystem或ComputerName \ LocalSystem.该帐户没有密码.

LocalSystem Account The LocalSystem account is a predefined local account used by the service control manager. This account is not recognized by the security subsystem, so you cannot specify its name in a call to the LookupAccountName function. It has extensive privileges on the local computer, and acts as the computer on the network. Its token includes the NT AUTHORITY\SYSTEM and BUILTIN\Administrators SIDs; these accounts have access to most system objects. The name of the account in all locales is .\LocalSystem. The name, LocalSystem or ComputerName\LocalSystem can also be used. This account does not have a password.

这篇关于命令行中的任务计划程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆