Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Getting all installed apps from add remove programs of remote computers into excel

Hi,

I need a way to get all the installed applications in a machine to a excel file.I want to do this remotely.

Regards
Sharath
Avatar of zoofan
zoofan
Flag of United States of America image

I removed the word and excel version checks as the apps list includes the installed version of the office suite.

Output into a single excel csv doc
pcname,app,app,app,app

'===Start copy: getapps.vbs===
' ---------------------------------------------------------------'
' getappversions.vbs
' 'Sample VBScript to query remote computers
' 'and return versions for word and excel.
' ''Author Riley C. aka ZooFan
' '''Version 2.4 - August 2007
' ''''https://www.experts-exchange.com question ID: 22734176
' ---------------------------------------------------------------'
'
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 3 'FileObject Access Type
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 'FileObject Format Type
Dim objFso
Dim objWshshell
Dim objOutputFile
Dim strCurPath
Dim dte
Dim tme
Dim arrPCnames()
Dim intPCLoop      
Dim strNewFile
Dim strPCFile
Dim objPCOutputFile
      Set objFso = CreateObject("Scripting.FileSystemObject")
      Set objWshshell = WScript.CreateObject("WScript.Shell")
      strCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
      dte = Replace(FormatDateTime(date(),vbshortdate),"/","-")
      tme = Replace(Replace(FormatDateTime(now(),vbLongtime),":","-")," ","")
      strNewFile = strCurPath & "\" & tme & "_" & dte & ".csv"
      strPCFile = InputBox("Please enter the full path and file" & VbCrLf & "name of the file with the computer names.","Get application versions from remote computers..")
            If Not objFso.FileExists(strPCFile) Then
                  MsgBox "You must enter a valid full path and file name!",vbOKOnly,"Get application versions from remote computers.."
                WScript.Quit(0)
            Elseif strPCFile = "" Then
                  MsgBox "You must enter a filename!",vbOKOnly,"Get application versions from remote computers.."
                WScript.Quit(0)
            Else
            Call createoutputfile(strNewFile)
            Call readpclist(strPCFile)
            Set objOutputFile = objFso.OpenTextFile(strNewFile,ForWriting,TristateUseDefault)
                                                 For intPCLoop = LBound(arrPCnames) To UBound(arrPCnames)
                                                objOutputFile.WriteLine("Computer,Apps List")
                                                objOutputFile.WriteLine(arrPCnames(intPCLoop) & "," & InstalledApplications(arrPCnames(intPCLoop)))
                                                Next
                              objOutputFile.Close                                                
                  MsgBox "File has been processed, and results saved in " & strNewFile ,vbOKOnly,"Get application versions from remote computers."      
            End If
      WScript.Quit(0)                                    
Sub readpclist(strPcList)
Dim objPCnames
Dim objReadFile
Dim intLneCount
      Set objPCnames = objFso.GetFile(strPCFile)
      Set objReadFile = objPCnames.OpenAsTextStream(ForReading, TristateUseDefault)
            Do Until objReadFile.AtEndOfStream
                  ReDim Preserve arrPCnames(intLneCount)
                  arrPCnames(intLneCount) = objReadFile.ReadLine
                  intLneCount = intLneCount + 1
            Loop
      objReadFile.Close
End sub                                    
Sub createoutputfile(strNewFileName)
            If objFso.FileExists(strNewFileName) Then
                  objFso.deleteFile(strNewFileName)
            Else
                  Set objOutputFile = objFso.CreateTextFile(strNewFileName)
                  objOutputFile.Close      
            End If
End Sub
Function InstalledApplications(pcName)
Dim appsFile
Dim oRegistry
Dim sBaseKey
Dim iRc
Dim sKey
Dim arSubKeys()
Dim sValue
 Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
 Set oRegistry = GetObject("winmgmts://" & pcName & "/root/default:StdRegProv")
 sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
 iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)

 For Each sKey In arSubKeys
  iRC = oRegistry.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)
  If iRC <> 0 Then
   oRegistry.GetStringValue HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
  End If
  If sValue <> "" Then
  InstalledApplications = InstalledApplications & sValue & ","
   End If
 Next

End Function
'===End copy: getapps.vbs===


any problems let me know.  And I am alomost done with the script to create user folders with permissions but time to go to work so will not be able to finish until this evening.

zf
Avatar of bsharath

ASKER

I get this.

---------------------------
Windows Script Host
---------------------------
Script:      C:\Find all softwares installed in a remote machine.vbs
Line:      80
Char:      2
Error:      The remote server machine does not exist or is unavailable: 'GetObject'
Code:      800A01CE
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
oops forgot error checking,  sorry brb.



zf
ASKER CERTIFIED SOLUTION
Avatar of zoofan
zoofan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That one run ok?

zf
Thanks a lot i get this working great.

I get the output like this
Dev-chen-pc2193      Microsoft Office Enterprise 2007      Microsoft Internationalized Domain
Dev-chen-pc1728      Beyond Compare Version 2.2.7      Belarc Advisor 7.2      Citrix ICA

Any way to get this sorted.

I mean scan all rows and sort all Microsoft Office Enterprise 2007 in the same row and another software if detected in the same row and so on.

I think the best way for you to handle the sort is to import this output into a database(inventory) and then you can query the database for all machines that say have "MS Office Enterprise 2007".

With the shear volume of data youve been collecting on all the pc's with these scripts at this point a database is going to be your only realistic method of keeping accurate track and orginization of all this information.  Unless this is a one time shot your going to end up will csv files coming out your ears if you dont find somewhere to collectivly put the data.  And if it is a one time shot, sort the data in excel.


zf