zoukankan      html  css  js  c++  java
  • Windows exe开机启动 开机执行 服务器重启开启服务

    一、放到开机启动文件夹中

    最简单的方式,把需要启动的程序、服务的快捷方式或编写的bat文件放到windows的启动文件夹中,系统启动时会尝试执行此文件夹内的所有程序,

    启动文件位置:通过 win + r 打开运行,输入 shell:startUp 回车:

    放入快捷方式(或bat文件):

    放置文件时,系统可能有风险提示,允许即可,放好过后可以查看启动项;

    直接右键任务栏,打开任务管理器,在启动项查看:

    或者打开设置、应用、启动:

    二、添加到计划任务

    右键我的电脑,打开管理,展开系统工具,选中任务计划程序,点击创建基本任务(创建任务也可以,创建基本任务类似流程向导):

    编辑自己需要的计划名,最好简单描述:

    选择触发器,或者执行频率,一般启动执行,也可以写好bat,每天执行一次,通过bat判断目标程序、服务是否在运行,没有则启动:

    操作就是启动程序:

    下一步选择脚本或程序,此处选择了bat脚本:

    完成:

    完成时可以勾选打开任务属性对话框,或者展开任务计划程序库,在列表中找到刚才添加的任务,右键打开属性:

    可以重新编辑触发器和操作:

    附:bat脚本代码:判断程序是否在运行,没有则启动,启动多个任务

    @echo off
    
    ::备注信息1
    tasklist|find /i "server1.exe" && echo started || start "serverName1" "server1.exe"
    
    ::备注信息2
    tasklist|find /i "server2.exe" && echo started || start "serverName2" "server2.exe" 
    
    ::备注信息3
    tasklist|find /i "server3.exe" && echo started || start "serverName3" "server3.exe" 

      

     检查程序是否运行:

    tasklist|find /i "server1.exe"

    并且判断是否要启动程序:
    && echo started || start "serverName1" "server1.exe"

    start "serverName1" "server1.exe":以名称 serverName1 启动程序 server1.exe ,名称可以是空串,程序此处是相对路径,和bat同位置,也可以填写绝对路径:"C:UsersHPDesktoplogserve.exe"。
     
  • 相关阅读:
    Interview with BOA
    Java Main Differences between HashMap HashTable and ConcurrentHashMap
    Java Main Differences between Java and C++
    LeetCode 33. Search in Rotated Sorted Array
    LeetCode 154. Find Minimum in Rotated Sorted Array II
    LeetCode 153. Find Minimum in Rotated Sorted Array
    LeetCode 75. Sort Colors
    LeetCode 31. Next Permutation
    LeetCode 60. Permutation Sequence
    LeetCode 216. Combination Sum III
  • 原文地址:https://www.cnblogs.com/jiayouba/p/14839863.html
Copyright © 2011-2022 走看看