我想將註冊表項及其子項導出爲XML友好格式,而不是.REG。這將僅用於報告目的,而不是稍後導入。將註冊表樹導出爲XML
當執行下面的代碼時,它給了我想要的數據,只是不兼容XML。任何關於如何創建一個批處理文件/ vbs的建議,將做我所需要的?
REG QUERY hklm\software\microsoft\windows\currentversion\uninstall /s
我想將註冊表項及其子項導出爲XML友好格式,而不是.REG。這將僅用於報告目的,而不是稍後導入。將註冊表樹導出爲XML
當執行下面的代碼時,它給了我想要的數據,只是不兼容XML。任何關於如何創建一個批處理文件/ vbs的建議,將做我所需要的?
REG QUERY hklm\software\microsoft\windows\currentversion\uninstall /s
我終於明白了我自己的想法。我使用for循環來枚舉每個註冊表項,然後使用echo命令將信息輸出到CSV文件和XML文檔中。對於那些可能想要嘗試去做的人來說,這是一個例子。 (不是我的確切代碼)
Echo ^<?xml version="1.0" encoding="ISO-8859-1"?^> >>myxml.xml
Echo ^<document^> >>myxml.xml
Echo ^<Computer Name="%Computername%"^> >>myxml.xml
Echo ^<Applications^> >>myxml.xml
for /f "tokens=7 delims=\" %%a in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall ^|findstr /v "KB1 KB2 KB3 KB4 KB5 KB6 KB7 KB8 KB9"') do (
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".displayVersion">version.txt
for /f "tokens=3*" %%c in (version.txt) do echo %%c %%d>version1.txt
if EXIST version1.txt set /p version=<version1.txt
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".displayName">Name.txt
for /f "tokens=3*" %%e in (Name.txt) do echo %%e %%f>Name1.txt
if EXIST name1.txt Set /p name=<name1.txt
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".InstallDate">InstallDate.txt
for /f "tokens=3*" %%j in (Installdate.txt) do echo %%j %%k>InstallDate1.txt
IF EXIST Installdate1.txt set /p installdate=<Installdate1.txt
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".UninstallString">UString.txt
for /f "tokens=3*" %%l in (Ustring.txt) do echo %%l %%m>Ustring2.txt
if exist Ustring2.txt type Ustring2.txt|findstr /v "&">Ustring1.txt
IF EXIST Ustring1.txt set /p Ustring=<Ustring1.txt
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".Publisher">Publisher.txt
for /f "tokens=3*" %%n in (Publisher.txt) do echo %%n %%o>Publisher1.txt
IF EXIST Publisher1.txt set /p Publisher=<Publisher1.txt
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%%a" |Findstr /i ".InstallLocation">Installloc.txt
for /f "tokens=3*" %%v in (Installloc.txt) do echo %%v %%w>Installloc1.txt
IF EXIST Installloc1.txt set /p Installloc=<Installloc1.txt
if NOT defined installdate set installdate=N/A
if NOT defined name set name=%%a
if NOT defined version set version=N/A
if NOT defined Ustring set Ustring=N/A
if NOT defined Publisher set Publisher=N/A
if NOT defined Installloc set Installloc=N/A
echo !name:^&=!'!version!'!Publisher:^&=!'!Installdate!'!Installloc:^&=!'!UString! >>programlist.csv
)
::Now Creating XML from CSV
for /f "tokens=1-6 delims='" %%p in (programlist.csv) DO (
echo ^<Product Name="%%p"^> >>myxml.xml
echo ^<Version^>%%q^</Version^> >>myxml.xml
echo ^<Publisher^>%%r^</Publisher^> >>myxml.xml
echo ^<Installdate^>%%s^</Installdate^> >>myxml.xml
echo ^<installLocation^>%%t^</installLocation^> >>myxml.xml
echo ^<UninstallString^>%%u^</UninstallString^> >>myxml.xml
echo ^</Product^> >>myxml.xml
)
Echo ^</Applications^> >>myxml.xml
echo ^</Computer^> >>myxml.xml
一個計劃:
(如果你發佈了一個體面的計劃,我願意幫助你實現。)