使用命令行创建在特定用户登录名上运行的计划任务 [英] Create a scheduled task that runs on particular user login using commandline

查看:80
本文介绍了使用命令行创建在特定用户登录名上运行的计划任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个计划任务,该任务在特定用户登录时运行一次.目的是仅针对特定用户启动任务.

I have the requirement to create a scheduled tasks that runs once when a particular user logs on. The intention is to start a task only for a particular user.

我知道我可以使用任务计划程序创建带有触发器的任务登录时,然后在设置"下指定特定用户.

I know that I can use the Task Scheduler to create a Task with a trigger At log on and under Settings, I specify the particular user.

但是,由于我需要在安装例程中创建此文件,因此必须使用命令行(例如,使用 schtasks 命令)自动创建它.可以使用以下示例创建登录时执行的任务:

However, because I need this created during an install routine, it must be created automatically, using the command line, for example using the schtasks command. It is possible to create a task executed at log on using the following example:

schtasks /Create /TR executable.exe /RU user /TN name /SC ONLOGON

但是我没有找到任何修饰符来指定 ONLOGON 触发器的特定用户.

But I did not find any modifier to specify a particular user for the ONLOGON trigger.

资源:

  • http://technet.microsoft.com/en-us/library/bb490996.aspx
  • http://ss64.com/nt/schtasks.html

您知道是否存在任何未记录的开关?还是其他任何提供必要功能的命令行工具?

Do you know if there is any undocumented switch? Or any other commandline tool that provides the necessary features?

谢谢.

推荐答案

我不知道任何此类选项.不幸的是,schtasks命令不能涵盖Task Scheduler 2.0提供的所有功能.您可以使用运行键或登录脚本.

I'm not aware of any such option. Unfortunately the schtasks command does not cover all features Task Scheduler 2.0 provides. You could accomplish this with a VBScript using the Task Scheduler Scripting Objects, however, it deems me quite troublesome to (ab)use Task Scheduler for something that could be achieved far easier with a Startup shortcut, a registry entry in the user's Run key, or a logon script.

这篇关于使用命令行创建在特定用户登录名上运行的计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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