Windows Task Scheduler Installer

后端 未结 2 838
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 20:01

I have a little .exe written in c# .net that I want to run on the server every 24 hours. So naturally I would just use the Windows Task Schedular rather then doing the math

相关标签:
2条回答
  • 2021-01-12 20:24

    I know this is an old question, but I figure this may help someone else:

    You can use the following to run in 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"
    

    This will loop through the list of servers in a text file (1 server per line) and use psexec to call schtasks on each server and install your task.

    0 讨论(0)
  • 2021-01-12 20:30

    You can use a powershell script or batch file to execute schtasks which is a command line interface to the task scheduler.

    Then you simply need to run the script in order to setup the scheduled task.

    There is also a managed wrapper that allows you to create schedules tasks in C#, if you would rather go that way.

    0 讨论(0)
提交回复
热议问题