本帖最后由 hentai87 于 2020-6-4 15:22 编辑
不想直接复制一次,以后要是改的话要改2个地方,而且复制2次,会加长代码
顺便问下,怎么优化括号,很多for 和if 弄的括号很多很乱- @echo off
- cd /d %~dp0
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
- taskkill /f /im DismHost.exe
- taskkill /f /im dism.exe
- setlocal EnableDelayedExpansion
-
- ::-------------------第一次
- for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
- for /f "skip=%n% delims=" %%b in (..\set.txt) do (
- for /f "tokens=1,2* delims=: " %%A in ('%%b\Bin\x64\DISM10\dism.exe /NoRestart /image:%%b\Mount\Install /Get-Capabilities') do (
-
- if "%%A %%B"=="Capability Identity" (
- set CapId=%%C
- ) else if "%%A"=="State" if "%%B"=="Installed" (
- cd. >list.txt
- echo !CapId!>>list.txt
-
- findstr /g:black_list.txt /v list.txt 2>nul
- if errorlevel 2 (
- for /f "delims=" %%i in (list.txt) do (
- %%b\Bin\x64\DISM10\dism.exe /image:%%b\Mount\Install /Remove-Capability /CapabilityName:"%%i"
- )
- ) else (
- for /f "delims=" %%i in ('findstr /g:black_list.txt /v list.txt 2^>nul') do (
- %%b\Bin\x64\DISM10\dism.exe /image:%%b\Mount\Install /Remove-Capability /CapabilityName:"%%i"
- )
- ))))
-
- ::-------------------第二次
-
- endlocal
- pause
- exit /b
复制代码
|