如何获取控制面板添加/删除程序里的所有程序
如何获取添加删除里的 所有的程序不要用 打开控制面板 再获取控件信息来获取。。
有没有办法能隐式的获取。。
==你描述的是这样的吗?
#NoTrayIcon#include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
DIM $_REG,$_REG_DP="DisplayName",$_REG_DI="DisplayIcon",$_REG_US="UninstallString",$X=0
DIM $_REG_String="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$GUI=GUICreate("添加删除程序",820,400,-1,-1)
$Label_01=GUICtrlCreateLabel("添加删除程序",10,20,800,40,0x01)
$Button_01=GUICtrlCreateButton("卸载",10,370,150,20)
$Button_02=GUICtrlCreateButton("退出",660,370,150,20)
$Lv=GUICtrlGetHandle(GUICtrlCreateListView("",10,50,800,315, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))
_GUICtrlListView_SetExtendedListViewStyle($Lv,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_AddColumn($Lv, "", 20)
_GUICtrlListView_AddColumn($Lv, "列表",400)
_GUICtrlListView_AddColumn($Lv, "路径",355)
GUICtrlSetBkColor($Label_01, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($Button_01,"_Uninstall")
GUICtrlSetOnEvent($Button_02,"_EXIT")
GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT")
GUISetOnEvent($GUI_EVENT_MINIMIZE,"_MINIMIZE")
GUISetOnEvent($GUI_EVENT_RESTORE,"_RESTORE")
GUISetState()
for $i=1 to 1000
$_REG=RegEnumKey($_REG_String,$i)
If @error <> 0 then ExitLoop
if RegRead($_REG_String&$_REG,$_REG_DP)="" Then
Else
_GUICtrlListView_AddItem($Lv,$x+1,$x)
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_DP),1)
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_US),2)
$x=$x+1
EndIf
Next
While 1
sleep(10)
WEnd
func _EXIT()
Exit
EndFunc
func _MINIMIZE()
GUISetState(@SW_MINIMIZE)
EndFunc
func _RESTORE()
GUISetState(@SW_RESTORE)
EndFunc
func _Uninstall()
if _GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),2)="" then
MsgBox(16,"添加删除程序","文件不存在 !")
Else
if MsgBox(1,"添加删除程序",_GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),1)&@CRLF&@CRLF&"您确定要卸载此程序?")=1 then Run(_GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),2))
EndIf
EndFunc Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\software.tsv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallDate2 & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
在c:\software.tsv文件里,自己修改一下。 也可以用 RegEnumKey 查询注册表键来获取
回复 2# ddx13 的帖子
我能问下你这是 VB script吗??还是别的语言啊?? 如何用autoit编写啊??那些函数都没有啊谢谢!
回复发表人
seominho , 我不太明白你的问题==,能够用英文描述吗?是不是startup program?回复 5# techbytnt 的帖子
控制面板-〉添加删除程序 里头不是列出了已经安装的程序吗。。。 我想用数组获取那些程序然后列出那些程序。@_@
#NoTrayIcon<br />#include <GuiListView.au3><br />
#include <GuiConstantsEx.au3><br />
#include <WindowsConstants.au3><br />
<br />
Opt("GUIOnEventMode", 1)<br />
DIM $_REG,$_REG_DP="DisplayName",$_REG_DI="DisplayIcon",$_REG_US="UninstallString",$X=0<br />
DIM $_REG_String="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"<br />
<br />
$GUI=GUICreate("添加删除程序",820,400,-1,-1)<br />
$Label_01=GUICtrlCreateLabel("添加删除程序",10,20,800,40,0x01)<br />
$Button_01=GUICtrlCreateButton("卸载",10,370,150,20)<br />
$Button_02=GUICtrlCreateButton("退出",660,370,150,20)<br />
$Lv=GUICtrlGetHandle(GUICtrlCreateListView("",10,50,800,315, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))<br />
_GUICtrlListView_SetExtendedListViewStyle($Lv,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT,$LVS_EX_SUBITEMIMAGES))<br />
_GUICtrlListView_AddColumn($Lv, "", 20)<br />
_GUICtrlListView_AddColumn($Lv, "列表",400)<br />
_GUICtrlListView_AddColumn($Lv, "路径",355)<br />
<br />
<br />
GUICtrlSetBkColor($Label_01, $GUI_BKCOLOR_TRANSPARENT)<br />
GUICtrlSetOnEvent($Button_01,"_Uninstall")<br />
GUICtrlSetOnEvent($Button_02,"_EXIT")<br />
GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT")<br />
GUISetOnEvent($GUI_EVENT_MINIMIZE,"_MINIMIZE")<br />
GUISetOnEvent($GUI_EVENT_RESTORE,"_RESTORE")<br />
GUISetState()<br />
<br />
<br />
for $i=1 to 1000<br />
$_REG=RegEnumKey($_REG_String,$i)<br />
If @error <> 0 then ExitLoop<br />
if RegRead($_REG_String&$_REG,$_REG_DP)="" OR StringLeft($_REG,1)="{" Then<br />
Else<br />
_GUICtrlListView_AddItem($Lv,$x+1,$x)<br />
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_DP),1)<br />
_GUICtrlListView_AddSubItem($Lv,$x,RegRead($_REG_String&$_REG,$_REG_US),2)<br />
$x=$x+1<br />
EndIf<br />
Next<br />
<br />
While 1<br />
sleep(10)<br />
WEnd<br />
<br />
func _EXIT()<br />
Exit<br />
EndFunc<br />
<br />
func _MINIMIZE()<br />
GUISetState(@SW_MINIMIZE)<br />
EndFunc<br />
<br />
func _RESTORE()<br />
GUISetState(@SW_RESTORE)<br />
EndFunc<br />
<br />
func _Uninstall()<br />
if _GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),2)="" then<br />
MsgBox(16,"添加删除程序","文件不存在 !")<br />
Else<br />
if MsgBox(1,"添加删除程序",_GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),1)&@CRLF&@CRLF&"您确定要卸载此程序?")=1 then Run(_GUICtrlListView_GetItemText($LV,_GUICtrlListView_GetSelectedIndices($lv),2))<br />
EndIf<br />
EndFunc 不懂是不是你所要的== 不过我也是写爽而已 =D:face (3):
回复 7# techbytnt 的帖子
谢谢, 这程序能获取一些不过获取的程序不到 添加删除程序里的一半。。。。。33行 "{" ------- 很多以这个开头的程序也在添加删除程序里头,所以很多程序没列出来。。。。
回复 10# techbytnt 的帖子
问题就出在这里 如果不判断 "{"这个的话很多程序是不在 添加删除程序里的。。。所以 要是这么得到的程序很多是不应该得到的。。。。 原帖由 techbytnt 于 2009-4-7 09:47 发表 http://www.autoitx.com/images/common/back.gif
seominho , 我不太明白你的问题==,能够用英文描述吗?是不是startup program?
如何让程序运行以后自动添加到 startup program 里啊??
回复 12#
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","MyProgram","REG_SZ",@scriptfullpath)或
RegWrite("HKEY_Current_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","MyProgram","REG_SZ",@scriptfullpath)
"MyProgram"=程序名
@scriptfullpath=程序路径 我用打开控制面板然后获取控件信息获取了程序列表,,
请教高手能否隐式的获取只有在添加删除程序里的程序。。。 原帖由 seominho 于 2009-4-7 09:30 发表 http://www.autoitx.com/images/common/back.gif
我能问下你这是 VB script吗??还是别的语言啊?? 如何用autoit编写啊??那些函数都没有啊
谢谢!
au3 wmi
:face (29):
页:
[1]
2