打包软件时,需要将cad字体复制到cad文字目录,写了个bat;
cad 软件版本很多,百度找了个查看目录的方法,就改了下,感觉遍历所有安装注册软件位置有点慢,有大神会bat的指点下,有其他方法方便获取吗?
参考:
https://bbs.csdn.net/topics/370146328
[PowerShell] 纯文本查看 复制代码
@echo off
rem 监测软件名称关键字
set dn=cad
rem 软件安装列表注册表位置
set rp=HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
call :start
set rp=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
call :start
set rp=HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall
call :start
echo 运行结束
pause
exit 0
:start
rem 查找安装名称%dn%
for /f "tokens=*" %%a in ('reg query "%rp%"') do (
for /f "tokens=*" %%l in ('reg query "%rp%\%%~na" /v "DisplayName" 2^>nul ^|findstr /i "%dn%"') do (
echo %%l |findstr /i "DisplayName" >nul &&call :show %%~na
)
)
goto :eof
:show
rem cls
rem 获取安装路径
for /f "tokens=*" %%b in ('reg query "%rp%\%1" /v "InstallLocation" 2^>nul ^|findstr /i "InstallLocation"') do (
set "CADPath=%%b"
call :cadFontCp
)
goto :eof
rem 查找安装目录下Fonts文件夹并复制文件
:cadFontCp
set "CADPath=%CADPath:~29%"
SetLocal EnableDelayedExpansion
if exist "%CADPath%Fonts" (
xcopy /y "%~dp0*.shx" "%cadPath%" 2>nul
)
goto :eof |