中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 14:38
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » Dear experts, please ask a question about judgment
Printable Version  2,484 / 0
Floor1 ydfan8888 Posted 2016-03-31 14:25
初级用户 Posts 20 Credits 60
You can modify the batch script as follows:

```batch
@echo off & setlocal enabledelayedexpansion
cd /d %~dp0
for /f "tokens=7* delims=\" %%i in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall') do (
reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%~i" reg.$ >nul
for /f "delims=" %%j in ('type reg.$ ^| findstr /i /c:"DisplayName" 2^>nul') do (
set DN=%%~j
set DN=!DN:"=!
)
for /f "delims=" %%k in ('type reg.$ ^| findstr /i /c:"InstallLocation" 2^>nul') do (
set IL=%%~k
set IL=!IL:"=!
set IL=!IL:\\=\!
)
if defined DisplayName (
if defined InstallLocation (
(echo ++++++++
echo 注册表值: %%~i
echo 软件名称: !DisplayName!
echo 安装路径: !InstallLocation!
echo,)>>1.txt
)
)
del reg.$
)
```

The main modification is to add conditional judgments. Only when both `DisplayName` and `InstallLocation` are defined will the relevant information be output to the text file, so as to achieve the effect of not writing the four lines corresponding to "Software Name: No information." into the text.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023