简单 windows
cmd
脚本例子
判断文件或文件夹是否存在
if not exist .git (
REM 判断 true 执行 git 命令
git init
) else (
REM 判断 false
echo skip git init
)
循环判断某进程是否存在,并执行相应事件
@echo off
REM 设置标题
title rest
REM 定义变量
:again
REM 任务列表 查询 指定可执行文件
tasklist|find /i "cci-agent.exe"
REM 判断结果
if ERRORLEVEL 1 (
REM 不存在
echo "start cci-agent.exe"
REM 执行文件
start D:\coding-runner\cci-agent.exe up -d --config D:\coding-runner\.coding
)
REM choice 延迟 /t 3600 秒
choice /t 3600 /d y /n >nul
REM 执行变量
goto again
来源:oschina
链接:https://my.oschina.net/u/3756690/blog/4916933