简体   繁体   English

如何使用Powershell脚本将.exe部署到调度程序任务

[英]How to deploy .exe to scheduler task using Powershell script

I developed a console app and scheduled it to run on Mon-Friday at 9:AM using windows task scheduler, it works fine. 我开发了一个控制台应用程序,并计划使用Windows任务计划程序将其运行在周一至周五的9:AM,它运行良好。

But I was asked to write Powershell scripts or command-line scripts for deployment, like the script should copy the "Release" folder to the server1(deployment env like dev, test or staging or prod) and schedule it in server1's schedule task. 但是我被要求编写Powershell脚本或命令行脚本进行部署,例如该脚本应将“ Release”文件夹复制到server1(部署环境,例如dev,test或staging或prod),并在server1的schedule任务中进行计划。 Also I have to set "Start in(optional)". 另外,我必须设置“开始于(可选)”。

I don't know anything about command-line and PS scripts. 我对命令行和PS脚本一无所知。 All it should do is create the windows schedule task just like the way I did using UI. 要做的就是像我使用UI一样创建Windows Schedule任务。

If I understand the question correctly you're just trying to create a scheduled task using powershell? 如果我正确理解了这个问题,那么您只是在尝试使用Powershell创建计划任务? If so try starting here: https://blogs.technet.microsoft.com/heyscriptingguy/2015/01/13/use-powershell-to-create-scheduled-tasks/ 如果是这样,请尝试从此处开始: https : //blogs.technet.microsoft.com/heyscriptingguy/2015/01/13/use-powershell-to-create-scheduled-tasks/

I had a requirement to schedule an exe, this scheduled task should run every day Mon to Fri at desired time. 我有一个计划exe的要求,该计划的任务应在所需时间周一至周五每天运行。 I never wrote any batch files in last 15 years of my career :), took it up as it came in my way from my manager. 在我职业生涯的最后15年中,我从未写过任何批处理文件:),因为它是从我的经理那里拿来的,所以没有用。 Thanks to him or else I would have not known in this new world. 多亏他,否则我将在这个新世界里不认识。

echo off title My 1st batch file for Task scheduler SchTasks /Create /RU "system" /Sc WEEKLY /D MON,TUE,WED,THU,FRI /TN "Leads" /TR "C:/Some.exe" /ST 09:00 回显标题任务计划程序的第一个批处理文件SchTasks / Create / RU“ system” / Sc Week / D MON,TUE,WED,THU,FRI / TN“ Leads” / TR“ C:/Some.exe” / ST 09 :00

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在任务调度程序中使用 VBA 正确运行 powershell 脚本? - How to properly run a powershell script using VBA in a task scheduler? 如何在静默/隐藏模式下使用任务调度程序运行powershell脚本? - How to run powershell script using task scheduler in silent/hidden mode? 如何使用 powershell 脚本禁用任务调度程序作业 - How can i disable task scheduler jobs using powershell script 使用Windows Task Scheduler运行的PowerShell脚本未运行SQL Server SSIS DTEXEC.EXE作业 - PowerShell script run using Windows Task Scheduler is not running a SQL Server SSIS DTEXEC.EXE job Powershell 2.0脚本在cmd.exe中运行,但不在Task Scheduler中运行 - Powershell 2.0 Script Runs in cmd.exe but not Task Scheduler 使用Powershell脚本在Task Scheduler中创建文件夹 - Using Powershell script to create folder in Task Scheduler 使用Powershell脚本创建任务计划程序 - Creating a task scheduler using Powershell script 如何在Task Scheduler上执行PowerShell脚本? - How to execute PowerShell script on Task Scheduler? 如何使用 PowerShell 脚本在 Windows 任务计划程序中配置“如果任务已在运行,则以下规则适用”? - How to configure "If the task is already running, then the following rule applies" in Windows Task Scheduler using PowerShell script? 如何从Powershell脚本调用任务计划程序中的任务? - How to call a task in Task Scheduler from a Powershell script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM