如何将C#程序作为计划任务运行

如何将C#程序作为计划任务运行

本文介绍了如何将C#程序作为计划任务运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对C#还是很陌生,所以您将不得不忍受。



我开发了一个Windows窗体程序,该程序会在最后更新一些SQL记录。



下一步是我需要在服务器上安装程序并模拟在程序中单击按钮以成为计划的



我知道如何在启动程序并输入参数的服务器端设置任务。但是我不确定要实现此目的需要在程序中包括什么代码。

解决方案

我的建议是而不是从计划的任务运行基于GUI的/窗口式应用程序-实际上这通常是疯狂的。理想情况下,部署基于控制台的应用程序版本,该版本需要执行(可能带有参数参数)并且不需要任何用户(或准用户)交互。



如果您只是不能创建应用程序的系统版本,那么我猜您有两种选择,两种选择都非常丑陋:1)创建某种宏脚本而不是您执行程序,此脚本可以执行该程序并发出单击,2)通过调用按钮单击处理程序(可能基于参数使其在执行模式下具有双重性)在应用程序启动时执行单击。 / p>

I am still pretty much new to c# so you will have to bear with me.

I have developed a windows form program which updates some SQL records as an end of day process for one of our clients.

The next step is that I need to install the program on a server and simulate a button click in the program to become a scheduled task.

I know how to setup the task on the server side where you start program and enter the arguments. But I am unsure as to what code I need to include in my program to achieve this.

解决方案

My recommendation would be to get away from running a GUI-based/windowed application from a scheduled task - this is generally madness in practice. Ideally, deploy a console-based version of your application that requires execution (perhaps with parameter arguments) and doesn't require any user (or quasi-user-) interaction.

If you simply can't create a 'system version' of your application, then I guess you have two choices, both immensely ugly: 1) create some kind of macro script which is executed instead of your program, this script could execute the program and issue 'the click', 2) perform 'the click' on startup of your application by invoking the button click handler (maybe based on a parameter to give it a duality in execution modes.)

这篇关于如何将C#程序作为计划任务运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 19:05