by Andrew Johnstone
Today, an audit was performed on machines with Photoshop CS installed and having the Technical Director to physically go to each machine. I’m sure there are reporting tools more than likely built into windows, however i’m not aware of any or at least nothing springs to mind. As an after thought I quickly wrote up the following. This script will enumerate a network, and attempt to display the installed software and their version.
Also Monad (MSH, or Microsoft Command Shell) looks very promising for administration considering you can pipeline processes for example directly into an excel document or a chart. It would probably be even simpler to do in MSH too, however I believe each client would have to have MSH installed, although it can call into WMI, or COM objects.
Dim colDomains, colRole
Dim objDomain, objUseDomain, objWMIService, objRole
Dim strComputer, strComputerRole
Dim SearchProduct
Dim MsgOut
'Constants
Const SPACES = " "
'Initialize Section
strComputerRole = Spaces
Title="Search for installed product"
SearchProduct=InputBox(Title,Title,"Adobe")
Set colDomains = GetObject("WinNT:")
For Each objDomain in colDomains
Set objUseDomain = GetObject ("WinNT://" & objDomain.Name)
objUseDomain.Filter = Array("Computer")
ParseComputers
Next
Sub ParseComputers
On Error Resume Next
For Each strComputer In objUseDomain
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer.Name & "rootcimv2")
If Err.Number <> 0 Then
ErrorWrite
Else
DetectApplication
End If
Next
End Sub
Sub DetectApplication
On Error Resume Next
Dim Query
If SearchProduct <> EMPTY Then
Query = " WHERE Name LIKE '%"+SearchProduct+"%'"
End If
Set colProduct = objWMIService.ExecQuery ("SELECT * FROM Win32_Product"+Query)
For Each objProduct in colProduct
MsgOut = MsgOut + objProduct.Name + VBCRLF
Next
If Err.Number <> 0 Then
ErrorWrite
End If
End Sub
Sub ErrorWrite
MsgOut = MsgOut + "Error# " & Err.Number & " " & Err.Description & " For computer " & strComputer.Name & " in domain " & objUseDomain.Name & VBCRLF
Err.clear
strComputerRole = Spaces
End Sub
'Right Report line to console and clear variable for next iteration
Sub WriteReportLine
MsgOut = MsgOut + "Domain= " & objUseDomain.Name & " ComputerName= " & strComputer.Name & " Role= " & strComputerRole & VBCRLF
strComputerRole = SPACES
End Sub
MsgBox MsgOut
Andrew Johnstone is a software engineer / lead developer working at Everlution Software.
Ed.D
December 22nd, 2005 at 9:57 am
Hello Mate – this is really good and we are going to try it out today
thanks again and have a really good break
Ed.
Andrew Johnstone
December 22nd, 2005 at 12:56 pm
No problem, Ed:)
Wordpress replaced a single apostrophe, so you may have received a parse error on a comment, if you copied it from the above before. I’ve corrected this and replaced the character with its html entity, so you can copy it directly now.
Just a note, this should be executed under administrators rights or it will display permission denied. You can do this by executing the following.
runas \user:Administrator \env cmd
And executing in the new command line window.
cscript ts.vbs
You can write this information to you local filesystem by appending the vbs file with:
Dim FileSys, TestFile
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set TestFile= FileSys.CreateTextFile("c:Output.txt", True)
TestFile.Write MsgOut
TestFile.Close
Hopefully this works.