标题: [注册表类] [已解决]批处理在uninstall之后系统变量变为!newPath!23H2 [打印本页]
作者: BingjianREMIX 时间: 2023-8-3 01:02 标题: [已解决]批处理在uninstall之后系统变量变为!newPath!23H2
本帖最后由 BingjianREMIX 于 2023-9-15 22:23 编辑
如题,在如下代码中,执行后,前两项reg均可成功执行(达到预期效果),第三项reg是删除注册表指定一项系统变量,在本站找到过年代久远的贴,无帮助,想看看现在的结果能不能行
我也在其他地方了解过大概思路,就是先存储现在path以备份,然后拆分path每部分验证是否相同,将不相同的保存到newpath中,之后保存newpath
现代码出现系统变量为!newPath!23H2- :uninstall
- echo MICRODOS Version 24.0 23H2 is being completely removed from your computer!
- echo It is about a few seconds.PLEASE.WAIT!
- rd /q /s MICRODOS
- reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MICRODOS v24.0 23H2" /f
- reg delete "HKEY_CLASSES_ROOT\%ProgramName%" /f
- set "removePath=%programpath%\MICRODOS\MICRODOS Version 24.0 23H2.exe"
- for /f "tokens=2*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path') do (
- set "pathValue=%%B"
- )
- set "newPath="
- for %%A in (%pathValue%) do (
- if /i not "%%A"=="%removePath%" (
- set "newPath=!newPath!%%A;"
- )
- )
- echo Uninstall complete!
- echo Please push any key to continue!
- pause>nul
- goto :window
复制代码
作者: BingjianREMIX 时间: 2023-8-3 01:05
希望现在的代码能够尽量简洁一些,昨天已经通宵了一天,如没有及时回复,请见谅
作者: czjt1234 时间: 2023-8-3 06:10
第一行
setlocal enabledelayedexpansion
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |