如何在Windows终端中运行schtasks命令/ .cmd批处理文件(不以管理员身份运行)

时间:2016-09-04 12:47:40

标签: windows batch-file cmd schtasks.exe

打开一个Windows终端并以管理员身份运行,我可以成功运行schtasks命令而无需输入用户名和密码。

但是,如果我双击cmd打开一个Windows终端(不是以管理员身份运行),我得到访问拒绝错误。在这种情况下,如何运行schtasks在任务调度程序中创建任务?或者运行具有schtasks命令的.cmd批处理文件? 是否可以输入admin或当前登录用户名和密码来运行命令?

1 个答案:

答案 0 :(得分:0)

来自schtasks /create /?。第一组(/u/p)是您运行schtasks程序的人。第二组(/ru/rp)是任务应该运行的内容。所有子命令都可以使用/U/P

/U   username      Specifies the user context under which SchTasks.exe
                   should execute.

/P   [password]    Specifies the password for the given user context.
                   Prompts for input if omitted.

/RU  username      Specifies the "run as" user account (user context)
                   under which the task runs. For the system account,
                   valid values are "", "NT AUTHORITY\SYSTEM"
                   or "SYSTEM".
                   For v2 tasks, "NT AUTHORITY\LOCALSERVICE" and
                   "NT AUTHORITY\NETWORKSERVICE" are also available as well
                   as the well known SIDs for all three.

/RP  [password]    Specifies the password for the "run as" user.
                   To prompt for the password, the value must be either
                   "*" or none. This password is ignored for the
                   system account. Must be combined with either /RU or
                   /XML switch.