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.
```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.
