【批处理】批处理模板

概述:创建批处理的通用模板

模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@echo off
setlocal enabledelayedexpansion

echo 开始工作,当前目录为: %cd%

for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)

:start

:: 参数1为空情况下打印提示
if "%~1"=="" (
call :ColorText 0C "[Error]没有提供参数1"
echo.

call :UsagePrint
echo.

goto:eof
)


::bcdedit /set testsigning on

::启动
::bcdedit /debug on


goto:eof

:UsagePrint
call :ColorText 02 "[Usage]:"
echo.

call :ColorText 02 " %~nx0 [OutputDir] [ui version]"
echo.
goto:eof

:: call :ColorText 0C "red"
:: call :ColorText 0b "blue"
:: call :ColorText 02 "green"
:: call :ColorText 19 "yellow"
:: call :ColorText 2F "black"
:: call :ColorText 4e "white"
:ColorText
@echo off
:: 移除冒号
set "input=%~2"
set "input=!input::=:!"
<nul set /p ".=%DEL%" > "!input!"
findstr /v /a:%1 /R "^$" "!input!" nul
del "!input!" > nul 2>&1
goto :eof

pause

【批处理】批处理模板
https://hodlyounger.github.io/2025/01/07/A_OS/Windows/批处理/【批处理】批处理模板/
作者
mingming
发布于
2025年1月7日
许可协议