求助:for路径变量写入注册表多一个斜杠和引号- echo 搜索目標
- set /p FileName=[請輸入目標应用FileName如et.exe]
- if not defined FileName set "FileName=et.exe" && echo 搜索目標应用
-
- for %%d in (D) do (
- if exist %%d:\ (
- for /f "delims=" %%b in ('dir /a-d /s /b "%%d:\*%FileName%" 2^>nul') do (
- if /i "%%~nxb"=="%FileName%" (
- cd /d "%%~dpb"
- echo "%%~dpb"
- echo "%FileName%"
- ))))
-
- for %%i in ("%%~dpb\..\..") do (
- echo 当前WPS版本号是%%~nxi & set Version=%%~dpi & set Ver=%%~nxi
- echo "%%~dpi"
- echo "%%~nxi"
- echo "%Version%"
- echo "%Ver%"
- )
- ::
- echo 注册WPSksolaunch程序
- ::set /p Version=[請輸入WPS Office Version]
- echo 請按【任意鍵】開始注册...
- pause >nul 2>nul
-
- rem -----------------------------for Kingsoft ---------------------------
-
- rem -----------------------------for Office ---------------------------
- Rem D:\Program Files (x86)\Kingsoft\WPS Office\ksolaunch程序启用设置
-
- REG DELETE "HKCU\SOFTWARE\Kingsoft" /f
- REG ADD "HKCU\SOFTWARE\Kingsoft\Office\6.0\Common" /f
- reg add "HKCU\SOFTWARE\Kingsoft\Office\6.0\Common" /v "InstallRoot" /t REG_SZ /d "%Version%" /f
复制代码 多一个斜杠错误图:- echo 搜索目標
- set /p FileName=[請輸入目標应用FileName如et.exe]
- if not defined FileName set "FileName=et.exe" && echo 搜索目標应用
-
- for %%d in (D) do (
- if exist %%d:\ (
- for /f "delims=" %%b in ('dir /a-d /s /b "%%d:\*%FileName%" 2^>nul') do (
- if /i "%%~nxb"=="%FileName%" (
-
- cd /d "%%~dpb"
- echo "%FileName%"
- echo "%%~dpb"
- ))))
-
- for %%p in ("%%~dpb\..") do (
-
- echo 当前WPSInstallRoot是%%~dpp & set Version=%%~dpp
- rem set %%~dpp=!%%~dpp:~,-1!
- rem 使用set str=!str:~,-1!脱去环境变量路径中的最后一个斜线
-
- rem set "Version=%Version:"=%"
- rem 使用set "var=%var:"=%"脱去环境变量var字符串中可能出现的所有引号,如果var字符串外侧不出现引号则变量值不变
-
- echo "%Version%"
- )
- for %%i in ("%%~dpb\..\..") do (
-
- echo 当前WPS版本号是%%~nxi & set Ver=%%~nxi
- echo "%Ver%"
- )
- ::
- echo 注册WPSksolaunch程序
- ::set /p Version=[請輸入WPS Office Version]
- echo 請按【任意鍵】開始注册...
- pause >nul 2>nul
-
- rem -----------------------------for Kingsoft ---------------------------
-
- rem -----------------------------for Office ---------------------------
- Rem D:\Program Files (x86)\Kingsoft\WPS Office\ksolaunch程序启用设置
-
- REG DELETE "HKCU\SOFTWARE\Kingsoft" /f
- REG ADD "HKCU\SOFTWARE\Kingsoft\Office\6.0\Common" /f
- reg add "HKCU\SOFTWARE\Kingsoft\Office\6.0\Common" /v "InstallRoot" /t REG_SZ /d "%Version%" /f
复制代码 多一个引号错误图:
求指导写入注册表值为"D:\Program Files (x86)\Kingsoft\WPS Office\10.1.0.6660",谢谢!!
PS:请达人帮助优化下多条for 语句,实在不会写,全是网上搜索局部功能后拼接测试的 |