首页 > 编程知识 正文

windows 任务计划程序服务,windows任务计划命令

时间:2023-05-05 09:37:50 阅读:211803 作者:2384

1. 打开Visual Studio 2012新建一个project Solution;

2. 选择Windows->windows Service,修改服务名称:MyFirstService;

3. 在默认窗口Service1中右键Add Install,自动生成两个类。

  

4. 修改serviceInstaller1的属性:

   a)ServiceName =”Appinfo”;   //设置服务名称

   b)StartType = Automatic;      //启动的模式有三种:“自动”、“手动”、“禁用”。事实上,在“我的电脑”的“管理”->“服务”中,还有一种模式:“自动(延迟启动)”

   c)Modifiers=public;

还有一些属性,比如DisplayName对应下图中的“显示名称”,ServiceName对应下图中的“服务名称”,而(Name)则对应,这些属性都是可以进行相应的修改的

  

5. 设置serviceProcessInstaller1组件的属性

  1) Account = LocalSystem;  //为最大的权限此属性还包括:LocalService、networkService、User(默认状态,如果使用User,则在安装的时候需要提供用户名和密码),如需要详细了解该属性,可以参照:

http://technet.microsoft.com/zh-cn/system.serviceprocess.serviceprocessinstaller.account(VS.90).aspx

  2) Modifiers=public;

6. 生成解决方案:选择release模式右键生成解决方案,则在相应的路径当中就会出现MyFirstService.exe文件。

 

7.使用installutil安装新建好的MyFirstService,方法如下:

  一、打开Visual Studio 2008-> Visual Studio Tools-> Visual Studio 2008 Command Prompt。

  二、使用命令:installutil  (服务的绝对路径),点击运行,即可安装服务。(注:用命令:installutil  /u  (服务的绝对路径),点击运行,即可卸载服务)

如installutil e:testMyFirstServiceMyFirstServicebinreleaseappinfo.exe

 

上面服务的安装已经完成,下面介绍制定计划任务执行服务,主要做2个服务1.停止服务2.执行服务,循环每日执行任务,1可提前2大约90秒

1.其中主要设置:操作的参数为 net 参数为start appinfo

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。