如何在不提示输入密码的情况下设置计划任务 [英] How can I set scheduledtask without prompting for a password

查看:1060
本文介绍了如何在不提示输入密码的情况下设置计划任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要在Windows中设置计划任务。
为此,我使用ShellExecute函数调用schtasks.exe



我使用了以下代码:

  ShellExecute(NULL,_T(open),_T(schtasks.exe),_T(/ create / TN SampleSchedule / TR calc.exe / SC DAILY / ST 12:15:00 / SD 09/04/2012),_T(),0); 

但尚未创建预定任务。



但是当我将ShellExecute函数(显示命令提示符)的最后一个参数更改为1时

  ShellExecute(NULL,_T 打开),_T(schtasks.exe),_T(/ create / TN SampleSchedule / TR calc.exe / SC DAILY / ST 12:15:00 / SD 09/04/2012 ),1); 

显示命令提示符,并要求输入当前登录用户的密码。

/ RU SYSTEM正在运行,但我希望以当前登录的用户身份运行,而不需要输入密码....



有可能吗?

解决方案

改用ITaskScheduler COM接口。



使用它的示例此处这里


I have an application which needs to set a scheduled tasks in Windows. For this I have used the ShellExecute function to call the schtasks.exe

I have used the following code :

ShellExecute(NULL, _T("open"), _T("schtasks.exe"), _T("/create /TN SampleSchedule /TR calc.exe /SC DAILY /ST 12:15:00 /SD 09/04/2012"),_T(""),0);

but it has not created the scheduled task.

But when I changed the last parameter of ShellExecute function (display command prompt) to 1

ShellExecute(NULL, _T("open"), _T("schtasks.exe"), _T("/create /TN SampleSchedule /TR calc.exe /SC DAILY /ST 12:15:00 /SD 09/04/2012"),_T(""),1);

a command prompt displayed and it asked for the password of the current logged in user.

The /RU SYSTEM is working, but I would like to run as the current logged in user itself without asking for the password....

Is it possible? If yes, what should I do for that?

解决方案

Use ITaskScheduler COM interface instead.

Examples of using it here and here

这篇关于如何在不提示输入密码的情况下设置计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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