How can I set scheduledtask without prompting for a password

一个人想着一个人 提交于 2019-12-11 08:14:19

问题


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?


回答1:


Use ITaskScheduler COM interface instead.

Examples of using it here and here



来源:https://stackoverflow.com/questions/10069925/how-can-i-set-scheduledtask-without-prompting-for-a-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!