[英]Windows Task Scheduler Installer
我有一个用C#.net编写的小.exe文件,我希望每24小时在服务器上运行一次。 因此,我自然会只使用Windows Task Schedular而不是自己做数学。 我已经创建了程序,但是我想创建一个安装程序,它可以完成所有的设置。 有没有办法像Visual Studio设置项目那样呢? 如果没有的话,可以在安装后运行Powershell /批处理脚本吗?
底线:自动创建任务。
我知道这是一个老问题,但是我认为这可能会对其他人有所帮助:
您可以使用以下命令在cmd.exe中运行
FOR /F %1 IN ("path to text file containing list of servers") do psexec.exe \\%1 -u
"username to execute schtasks under" -p "password" schtasks /Create /S %1
/RU "username that will run the task" /RP "password" /XML "xml file of
the task to install" /TN "name of the task"
这将循环浏览文本文件中的服务器列表(每行1个服务器),并使用psexec在每个服务器上调用schtasks并安装任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.