windows 批处理(.bat)启动脚本 完全版

ps

*. 请勿使用中文文件名称

默认以管理员权限执行

%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0

缺少的功能

-. 启动脚本的命名

代码模板

:: 代码页更改为Unicode(UTF-8)
SET appName=server
SET port=1993
chcp 65001
title=%appName%:%port%

@echo off

::启动 redis_start
echo start redis_start
call start /d "D:\Redis-x64-3.2.100" redis_start.bat
::暂停几秒再执行后面的 命令
ping -n 5 127.1 >nul 2>nul
echo redis_start started!

::启动 nacos
echo start nacos
call start /d "D:\nacos\bin" startup.cmd
::暂停几秒再执行后面的 命令
ping -n 5 127.1 >nul 1>nul
echo nacos started!


::多行注释 start
goto start
... echo "abc"
... echo "def"
:start
::多行注释 end

pause

参考文档

核心启动代码
echo中文乱码
设置脚本名称

posted @ 2022-11-14 09:48  qoon  阅读(860)  评论(0编辑  收藏  举报