Thopaga Posted December 13, 2010 Posted December 13, 2010 Hello. I am wondering if someone can help me. I would like to make a script that can 'List Installed Programs' and check if a special product is installed or not. In addition I would like to get information about which 'Operating System' we are running on. I believe there would be some User functions or some ready script that can do these things. Maybe some of you have made functions that can get much information about the computer and its software. Thanks. Spoiler Sort a multi-dimensional array with multiple sort columns. Max 9 dimensions.
Steveiwonder Posted December 13, 2010 Posted December 13, 2010 (edited) Regarding the OS look at:@OSArch @OSBuild @OSLang @OsServicePack @OSType @OSVersionSee for install programsWelcome to the Forums, first tip - use the search function Edited December 13, 2010 by Steveiwonder They call me MrRegExpMan
Steveiwonder Posted December 13, 2010 Posted December 13, 2010 (edited) Based on script in the above linked post. It could use some tidying upexpandcollapse popupIf IsInstalled("ITunEs") == 1 Then ConsoleWrite("Installed") Else ConsoleWrite("Not installed") EndIf Func IsInstalled($progName) Local $InstallPrograms = GetList() If $InstallPrograms == -1 Then Return -1 ; Cannot get list For $program in $InstallPrograms if StringLower($program.Caption) == StringLower($progName) Then ConsoleWrite($program.Caption & " : " & $progName & @CRLF) Return 1; EndIf Next Return -2 ; Didn't find program. EndFunc Func GetList() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then Return $colItems EndIf Return -1 EndFunc Works for me. Edited December 13, 2010 by Steveiwonder They call me MrRegExpMan
iamtheky Posted December 13, 2010 Posted December 13, 2010 (edited) Here is my offering. Cant remember which thread I picked up the meat of this from but there is a ripdad modified function so its probably one of his.... expandcollapse popup#include <GuiListView.au3> Opt("TrayAutoPause", 0) Opt('GUIOnEventMode', 1) Opt('GUICloseOnEsc' , 1) Global $i Local $sSft Global $sGui = GUICreate('Currently Installed Software', 810, 650, -1, -1) Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600) _ComputerGetSoftware($sSft) For $i = 1 To ubound($sSft) - 1 GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw) Next GUICtrlSendMsg($sLvw, 0x101E, 1, 175) GUICtrlSendMsg($sLvw, 0x101E, 2, 65) GUICtrlSendMsg($sLvw, 0x101E, 3, 150) GUICtrlSendMsg($sLvw, 0x101E, 4, 350) Local $mMen = GUICtrlCreateContextMenu($sLvw) Local $CopI = GUICtrlCreateMenuItem('Uninstall Current Selection', $mMen) GUICtrlSetOnEvent($CopI, '_Uninstall') Local $exp = GUICtrlCreateButton(' Expand ', 720, 615) GUICtrlSetOnEvent($exp, '_Expand') GUISetOnEvent(-3, '_AllExit') GUISetState(@SW_SHOW, $sGui) While 1 Sleep(10) WEnd ; Func _AllExit() GUIDelete($sGui) Exit EndFunc ; Func _Uninstall() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then RunWait ($proc[5]) exit EndFunc ; Func _Copy2Clip() Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1) If $proc[1] == 0 Then Return -1 If $proc[5] Then ClipPut($proc[5]) EndFunc ; ; Author JSThePatriot - Modified June 20, 2010 by ripdad Func _ComputerGetSoftware(ByRef $aSoftwareInfo) Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Local $i = 1 Dim $aSoftwareInfo[1][4] $input = inputbox ("Which Software" , "You are running " & @OSVersion & " " & @OSARCH & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL') If @Error = 1 Then Exit If $input = 'ALL' Then For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then Exitloop If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo,0,1) Else For $j = 1 To 500 $AppKey = RegEnumKey($UnInstKey, $j) If @error <> 0 Then Exitloop $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName") $string = stringinstr($Reg, $input) If $string = 0 Then Continueloop ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4] $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3) $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3) $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3) $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3) $i = $i + 1 Next $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1 If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0) Return _ArraySort($aSoftwareInfo,0,1) Endif EndFunc ; Func _Expand() _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE) EndFunc Edited October 27, 2011 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Thopaga Posted December 13, 2010 Author Posted December 13, 2010 Thanks Steveiwonder, Thanks Iamtheky. I really appreciate your kind help. This was more than I expected. Thanks. Spoiler Sort a multi-dimensional array with multiple sort columns. Max 9 dimensions.
Berkermann Posted January 9, 2014 Posted January 9, 2014 (edited) Based on script in the above linked post. It could use some tidying up expandcollapse popupIf IsInstalled("ITunEs") == 1 Then ConsoleWrite("Installed") Else ConsoleWrite("Not installed") EndIf Func IsInstalled($progName) Local $InstallPrograms = GetList() If $InstallPrograms == -1 Then Return -1 ; Cannot get list For $program in $InstallPrograms if StringLower($program.Caption) == StringLower($progName) Then ConsoleWrite($program.Caption & " : " & $progName & @CRLF) Return 1; EndIf Next Return -2 ; Didn't find program. EndFunc Func GetList() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then Return $colItems EndIf Return -1 EndFunc Works for me. Hi Steveiwonder, your script is excatly what i need, but every time i try ist, it still says "not installed" what's wrong? i need a script, where i can have 10 lines with rpogrames that should checked... like TeamViewer --> installed Java --> installed or not Please help Edited January 9, 2014 by Berkermann
Moderators JLogan3o13 Posted January 9, 2014 Moderators Posted January 9, 2014 Hi, Berkermann. Please refrain from resurrecting 3 year old posts. What worked in 2010 may not work the same in 2014 (especially with the recent upgrade). You will receive a much better response if you open a new thread, explaining exactly what you are trying to accomplish and what you have tried on your own "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now