Batch file 从导出的注册表信息排列结果格式时出现问题

Batch file 从导出的注册表信息排列结果格式时出现问题,batch-file,Batch File,我使用批处理脚本从我的PC注册表中将已安装的程序列表导出为文本文件 @echo off echo ================== reg export HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp1.txt findstr /L /C:"DisplayName" /C:"DisplayVersion" temp1.txt >> temp3.txt for /f

我使用批处理脚本从我的PC注册表中将已安装的程序列表导出为文本文件

@echo off
echo ==================

reg export HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp1.txt
findstr /L /C:"DisplayName" /C:"DisplayVersion" temp1.txt >> temp3.txt
for /f "tokens=2,3 delims==" %%i in (temp3.txt) do (echo %%i)

但是,我无法将这些结果重新排列为名称和版本格式。

这类似于我从中执行的方式,但仅针对您问题中的单个特定注册表项(我会要求PowerShell执行)

@Set“KP=SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”
@设置/A W=90,H=120
@PowerShell-NoP“&{$H=Get Host;$R=$H.UI.RawUI;$B=$R.BufferSize;”^
“$W=$R.WindowsSize;$B.Width=如果(%W%-GT$W.Width){%W%}否则{$W.Width};”^
“$B.Height=如果(%H%-GT$W.Height){%H%}其他{$W.Height};$R.BufferSize=$B};”^
“GP'HKLM:\%KP%\*'-EA SilentlyContinue |?{$\uu0.DisplayName-NE$Null}”^
“选择DisplayName,DisplayVersion | FT-A-H”
@停顿
请注意,您的注册表项
HKEY\U LOCAL\U MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
不是唯一可以找到已安装软件的位置,它们也可以在
HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
下找到,
HKEY\u CURRENT\u USER\Software\Microsoft\Windows\CurrentVersion\Uninstall
,以及
HKEY\u CURRENT\u USER\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

纯批处理解决方案(对于人眼来说输出效果不太好,但对于
csv
来说非常好,而且速度更快(因为不加载PowerShell)(与COMO回答中的注释相同):


reg export
写UTF16,所以我没有使用
findstr…temp1.txt
,而是使用
键入temp1.txt | findstr…
来正确处理文件。

请不要对我们大喊大叫,这很粗鲁。或者检查键盘以确保没有激活caps lock键。欢迎这样做。你的问题可能是正确的,但缺少一些细节s、 顺便问一下:你的问题是什么?(“我该怎么做…,“为什么…?”)请花点时间阅读本文和其中的一些:。否则你的问题将结束。你想得到什么?类似于
DisplayName,DisplayVersion
VLC media player,3.0.12
)的内容?非常有用,谢谢
@echo off
setlocal enabledelayedexpansion
reg export HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp1.txt
for /f "tokens=1,* delims==" %%a in ('type temp1.txt^|findstr /L /C:"DisplayVersion" /c:"DisplayName"') do (
  if "%%~a" == "DisplayName"  set "name=%%~b"
  if "%%~a" == "DisplayVersion" echo !name!, %%~b
)