Created
October 17, 2013 13:16
-
-
Save wpsmith/7024735 to your computer and use it in GitHub Desktop.
VBS: Get All Softwares on Machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set wShell = CreateObject("WScript.Shell") | |
Set whoami = wShell.Exec("whoami /groups") | |
Set whoamiOutput = whoami.StdOut | |
strWhoamiOutput = whoamiOutput.ReadAll | |
If InStr(1, strWhoamiOutput, "S-1-16-12288", vbTextCompare) Then | |
isElevated = True | |
Else | |
isElevated = False | |
End If | |
If Not isElevated Then | |
'Re-runs the process prompting for priv elevation on re-run | |
'Check If we need to run in C or W script | |
interpreter = "wscript.exe" | |
If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then | |
interpreter = "wscript.exe" | |
Else | |
interpreter = "cscript.exe" | |
End If | |
'Start a new instance with an elevation prompt first | |
Set shellApp = CreateObject("Shell.Application") | |
shellApp.ShellExecute interpreter, Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1 | |
'End the non-elevated instance | |
WScript.Quit | |
End If | |
'Written by Hari Shankar Das | |
'Published by www.funbutlearn.com | |
'********* Use YES/NO to export or Not to export a column ************** | |
col1=Array("AssignmentType","NO") | |
col2=Array("Caption","NO") | |
col3=Array("Description","YES") | |
col4=Array("IdentIfyingNumber","YES") | |
col5=Array("InstallDate","YES") | |
col6=Array("InstallDate2","NO") | |
col7=Array("InstallLocation","YES") | |
col8=Array("InstallState","NO") | |
col9=Array("HelpLink","NO") | |
col10=Array("HelpTelephone","NO") | |
col11=Array("InstallSource","NO") | |
col12=Array("Language","NO") | |
col13=Array("LocalPackage","NO") | |
col14=Array("Name","YES") | |
col15=Array("PackageCache","NO") | |
col16=Array("PackageCode","NO") | |
col17=Array("PackageName","NO") | |
col18=Array("ProductID","NO") | |
col19=Array("RegOwner","NO") | |
col20=Array("RegCompany","NO") | |
col21=Array("SKUNumber","NO") | |
col22=Array("Transforms","NO") | |
col23=Array("URLInfoAbout","NO") | |
col24=Array("URLUpdateInfo","NO") | |
col25=Array("VEndor","YES") | |
col26=Array("WordCount","NO") | |
col27=Array("Version","YES") | |
Set objFile = CreateObject("Scripting.FileSystemObject") | |
'Get Network | |
Set objNetwork = CreateObject("Wscript.Network") | |
strFile = "C:\Users\"+objNetwork.UserName+"\Desktop\InstalledApps.csv" | |
Set csvFile = objFile.CreateTextFile(strFile) | |
Set WMIObject = GetObject("winmgmts:\\.\root\cimv2") | |
Set resultSet = WMIObject.ExecQuery ("SELECT * FROM Win32_Product") | |
Msgbox "Export to csv will begin now. It may take some seconds.",vbokonly,"Message" | |
If(col1(1)="YES") Then header=header & col1(0) & "," End If | |
If(col2(1)="YES") Then header=header & col2(0) & "," End If | |
If(col3(1)="YES") Then header=header & col3(0) & "," End If | |
If(col4(1)="YES") Then header=header & col4(0) & "," End If | |
If(col5(1)="YES") Then header=header & col5(0) & "," End If | |
If(col6(1)="YES") Then header=header & col6(0) & "," End If | |
If(col7(1)="YES") Then header=header & col7(0) & "," End If | |
If(col8(1)="YES") Then header=header & col8(0) & "," End If | |
If(col9(1)="YES") Then header=header & col9(0) & "," End If | |
If(col10(1)="YES") Then header=header & col10(0) & "," End If | |
If(col11(1)="YES") Then header=header & col11(0) & "," End If | |
If(col12(1)="YES") Then header=header & col12(0) & "," End If | |
If(col13(1)="YES") Then header=header & col13(0) & "," End If | |
If(col14(1)="YES") Then header=header & col14(0) & "," End If | |
If(col15(1)="YES") Then header=header & col15(0) & "," End If | |
If(col16(1)="YES") Then header=header & col16(0) & "," End If | |
If(col17(1)="YES") Then header=header & col17(0) & "," End If | |
If(col18(1)="YES") Then header=header & col18(0) & "," End If | |
If(col19(1)="YES") Then header=header & col19(0) & "," End If | |
If(col20(1)="YES") Then header=header & col20(0) & "," End If | |
If(col21(1)="YES") Then header=header & col21(0) & "," End If | |
If(col22(1)="YES") Then header=header & col22(0) & "," End If | |
If(col23(1)="YES") Then header=header & col23(0) & "," End If | |
If(col24(1)="YES") Then header=header & col24(0) & "," End If | |
If(col25(1)="YES") Then header=header & col25(0) & "," End If | |
If(col26(1)="YES") Then header=header & col26(0) & "," End If | |
If(col27(1)="YES") Then header=header & col27(0) & "," End If | |
csvFile.WriteLine mid(header,1,len(header)-1) | |
For Each app in resultSet | |
If(col1(1)="YES") Then rowData=rowData & """" & app.AssignmentType & """" & "," End If | |
If(col2(1)="YES") Then rowData=rowData & """" & app.Caption & """" & "," End If | |
If(col3(1)="YES") Then rowData=rowData & """" & app.Description & """" & "," End If | |
If(col4(1)="YES") Then rowData=rowData & """" & app.IdentIfyingNumber & """" & "," End If | |
If(col5(1)="YES") Then rowData=rowData & """" & app.InstallDate & """" & "," End If | |
If(col6(1)="YES") Then rowData=rowData & """" & app.InstallDate2 & """" & "," End If | |
If(col7(1)="YES") Then rowData=rowData & """" & app.InstallLocation & """" & "," End If | |
If(col8(1)="YES") Then rowData=rowData & """" & app.InstallState & """" & "," End If | |
If(col9(1)="YES") Then rowData=rowData & """" & app.HelpLink & """" & "," End If | |
If(col10(1)="YES") Then rowData=rowData & """" & app.HelpTelephone & """" & "," End If | |
If(col11(1)="YES") Then rowData=rowData & """" & app.InstallSource & """" & "," End If | |
If(col12(1)="YES") Then rowData=rowData & """" & app.Language & """" & "," End If | |
If(col13(1)="YES") Then rowData=rowData & """" & app.LocalPackage & """" & "," End If | |
If(col14(1)="YES") Then rowData=rowData & """" & app.Name & """" & "," End If | |
If(col15(1)="YES") Then rowData=rowData & """" & app.PackageCache & """" & "," End If | |
If(col16(1)="YES") Then rowData=rowData & """" & app.PackageCode & """" & "," End If | |
If(col17(1)="YES") Then rowData=rowData & """" & app.PackageName & """" & "," End If | |
If(col18(1)="YES") Then rowData=rowData & """" & app.ProductID & """" & "," End If | |
If(col19(1)="YES") Then rowData=rowData & """" & app.RegOwner & """" & "," End If | |
If(col20(1)="YES") Then rowData=rowData & """" & app.RegCompany & """" & "," End If | |
If(col21(1)="YES") Then rowData=rowData & """" & app.SKUNumber & """" & "," End If | |
If(col22(1)="YES") Then rowData=rowData & """" & app.Transforms & """" & "," End If | |
If(col23(1)="YES") Then rowData=rowData & """" & app.URLInfoAbout & """" & "," End If | |
If(col24(1)="YES") Then rowData=rowData & """" & app.URLUpdateInfo & """" & "," End If | |
If(col25(1)="YES") Then rowData=rowData & """" & app.VEndor & """" & "," End If | |
If(col26(1)="YES") Then rowData=rowData & """" & app.WordCount & """" & "," End If | |
If(col27(1)="YES") Then rowData=rowData & """" & app.Version & """" & "," End If | |
csvFile.WriteLine mid(rowData,1,len(rowData)-1) | |
rowData="" | |
Next | |
Msgbox "Data exported successfully",vbokonly,"Done" | |
csvFile.Close | |
Set objSysInfo = Createobject("ADSystemInfo") | |
'DN of current user: CN=Smith Traivs (DTH8HXG),OU=Users,OU=ATL,DC=us,DC=ups,DC=com | |
'Copy File to Server | |
Msgbox "Copying file to Server.",vbokonly,"Message" | |
'strDestFolder = "\\SVRP0001F10E\Training Dev\00_TD Technology & Support Team\Software\Users\"+objNetwork.UserName+"\" | |
'strDestFolder = "\\SVRP0001F10E\gln\CorpLD\GLN\Technology\Software\Users\"+objNetwork.UserName+"\" | |
strDestFolder = "\\SVRP0001F10E\gln\CorpLD\GLN\Technology\Software\Users\"+objNetwork.UserName | |
If NOT objFile.FolderExists(strDestFolder) Then objFile.CreateFolder(strDestFolder) | |
objFile.CopyFile strFile, strDestFolder, true | |
Msgbox "Copied. Emailing...",vbokonly,"Message" | |
Set outlookApp = CreateObject("Outlook.Application") | |
Set objMailItem = outlookApp.CreateItem(olMailItem) | |
'comment the next line If you do Not want to see the outlook window | |
objMailItem.Display | |
objMailItem.Recipients.Add "travis.smith@ups.com" | |
objMailItem.Subject = "My Software List" | |
objMailItem.Body = "My Software List."+objSysInfo.UserName | |
objMailItem.Attachments.Add strFile | |
objMailItem.Send | |
Set objMailItem = Nothing | |
Set outlookApp = Nothing | |
Msgbox "Done!",vbokonly,"Done" | |
'Delete files | |
If objFile.FileExists(strFile) Then | |
objFile.DeleteFile(strFile) | |
End If |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment