windows 如何在 C/C++ 中以编程方式创建计划任务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4110613/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:33:40  来源:igfitidea点击:

How to create a Scheduled Task programatically in C/C++?

cwindowsscheduled-tasks

提问by kampi

I created a small application which makes some settings. I want to start this application before a user logs into windows. Unfortunately i didn't find any solution for this problem, so i thought i could create a scheduled task. Unfortunately i didn't find any solution neither for this. So my question is, that could somebody help me? I would appropritiate any help, idees, or examples. Basicly my question is, how can i start an application before a user logs into windows? It is necessary to mention that i need to this on Windows XP!

我创建了一个小应用程序,它进行了一些设置。我想在用户登录 Windows 之前启动此应用程序。不幸的是我没有找到解决这个问题的任何方法,所以我想我可以创建一个计划任务。不幸的是,我也没有为此找到任何解决方案。所以我的问题是,有人可以帮助我吗?我会适当地提供任何帮助、想法或示例。基本上我的问题是,如何在用户登录 Windows 之前启动应用程序?有必要提一下,我需要在 Windows XP 上这样做!

回答by DennyRolling

Look into MSDNfor Task Scheduler API.

查看MSDN中的 Task Scheduler API。

Creating a Task Using NewWorkItem Exampleseems to be what you are describing here.

使用 NewWorkItem 示例创建任务似乎就是您在此处描述的内容。

回答by prolink007

Link to the below thread

链接到以下线程

You can do this in Windows XP Pro..

"Start" "Run" type gpedit.msc

Under "Computer Configuration" "Windows Settings" Double click "Scripts(Startup/Shutdown)" Double click "Startup" in right pane. Click "Add" button and browse to your program and then click "ok" then Click "Ok" again.

you can now exit out of all the Group Policy editor..

Now when Windows XP Pro boots up. before the user logs on this program will run for you.

您可以在 Windows XP Pro 中执行此操作。

“开始”“运行”输入 gpedit.msc

在“计算机配置”“Windows 设置”下双击“脚本(启动/关机)”在右侧窗格中双击“启动”。单击“添加”按钮并浏览到您的程序,然后单击“确定”,然后再次单击“确定”。

您现在可以退出所有组策略编辑器..

现在,当 Windows XP Pro 启动时。在用户登录之前,此程序将为您运行。