首页 > 技术文章 > AutoIt:获取计算机已安装程序列表

autotest 2013-08-28 09:59 原文

$file = FileOpen(@ScriptDir&"\RegInstalledItems.csv",1)
if $file = -1 Then
	ConsoleWrite("ERROR: Unable to write to the output file")
	Exit
EndIf

$i = 1
While not @error
	$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)
	If @error <> 0 then ExitLoop
	;MsgBox(4096, "SubKey #" & $i & " under HKLM\Software: ", $var)
	$var2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$var,"DisplayName")
	;MsgBox(0,"Val",$var2)
	$outLine = $var&","&$var2
	FileWriteLine($file,$outLine)
	$i += 1
WEnd
FileClose($file)

  

在使用autoIt的过程中,无论是自动化测试,还是界面开发,经常性的会需要获取已安装程序列表,从而判断某程序是否已经安装。

下面提供一个可以运行的代码段(Google获取的)

 

推荐阅读