Hi,

I am new to vbscript i want to know whether i can run vbscript in multiple sytems remotely at a time for getting listed installed programs.Do i need admin rights in order to run this script.Can any one post the script if you have come across this issue.

Thanks
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
There are a number of ways you can come up with a solution. Whether or not you need admin rights is dependent upon your environment. You won't necessarily need admin rights, but you'll need enough authority to read the Uninstall key in the registry. If you use logon scripts, that is probably the easiest way to handle this.
Answered 12/16/2009 by: airwolf
Tenth Degree Black Belt

Please log in to comment
0
Thanks Andy for your reply like i said iam new to this my issue is i have to get the listed installed programs of each particular machine.Can you provide me the logon script.
Answered 12/16/2009 by: acbabu
Orange Belt

Please log in to comment
0
Check out the Domain Reporting Tool by MouseTrax (no affiliation). It is a monster script but code quality is good and it does what you want and more. I'll leave you to Google for it.
Answered 12/16/2009 by: VBScab
Red Belt

Please log in to comment
0
Thanks VBScab I found a script that gives me listed installed programs for local machine but with
error :invalid procedure call or argument
Code : 800A0005

Is it possible to add logon script in this script to run remotely for multiple systems

Thanks
Answered 12/16/2009 by: acbabu
Orange Belt

Please log in to comment
2
Error 5 (we can discard the rest of the digits bar the last 2 or 3) means 'Access Denied'. You need to use an account which has rights to write to OutFile's location.

Also, please use the CODE tag when posting code or other lengthy/formatted text.

Lastly, the log-in script is decidely NOT the place for a script like this, since you're likely to end up with garbled output, since there's no way to control when each client is going to write its list to OutFile. It would be more efficient to run a script like this centrally, preferably out of hours (if your machines are left on, of course), and pass in machine names from a domain query (or, if you must) a list of machines, perhaps contained in a file which the script reads.

As I mentioned, the MouseTrax script has done the majority of that work for you. I've found in the past that re-inventing the wheel isn't the most productive use of my time.
Answered 12/16/2009 by: VBScab
Red Belt

Please log in to comment
0
Thanks VBscab i really appreciate your help.
Answered 12/16/2009 by: acbabu
Orange Belt

Please log in to comment
0
Thanks VBscab i have admin access on my machine still iam getting same error

ERROR :Invalid Procedure call or argument
Code : 800A005

can you please try to figure it out here is the code


Option Explicit
Dim sTitle
sTitle = "InstalledPrograms.vbs by Bill James"
Dim StrComputer
strComputer = InputBox("Enter I.P. or name of computer to check for " & _
"installed software (leave blank to check " & _
"local system)." & vbcrlf & vbcrlf & "Remote " & _
"checking only from NT type OS to NT type OS " & _
"with same Admin level UID & PW", sTitle)
If IsEmpty(strComputer) Then WScript.Quit
strComputer = Trim(strComputer)
If strComputer = "" Then strComputer = "."
'Wscript.Echo GetAddRemove(strComputer)
Dim sCompName : sCompName = GetProbedID(StrComputer)
Dim sFileName
sFileName = sCompName & "_" & GetDTFileName() & "_Software.txt"
Dim s : s = GetAddRemove(strComputer)
If WriteFile(s, sFileName) Then
'optional prompt for display
If MsgBox("Finished processing. Results saved to " & sFileName & _
vbcrlf & vbcrlf & "Do you want to view the results now?", _
4 + 32, sTitle) = 6 Then
WScript.CreateObject("WScript.Shell").Run sFileName, 9
End If
End If
Function GetAddRemove(sComp)
'Function credit to Torgeir Bakken
Dim cnt, oReg, sBaseKey, iRC, aSubKeys
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
sComp & "/root/default:StdRegProv")
sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)
Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay
For Each sKey In aSubKeys
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)
If iRC <> 0 Then
oReg.GetStringValue HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
End If
If sValue <> "" Then
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _
"DisplayVersion", sVersion)
If sVersion <> "" Then
sValue = sValue & vbTab & "Ver: " & sVersion
Else
sValue = sValue & vbTab
End If
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _
"InstallDate", sDateValue)
If sDateValue <> "" Then
sYr = Left(sDateValue, 4)
sMth = Mid(sDateValue, 5, 2)
sDay = Right(sDateValue, 2)
'some Registry entries have improper date format
On Error Resume Next
sDateValue = DateSerial(sYr, sMth, sDay)
On Error GoTo 0
If sdateValue <> "" Then
sValue = sValue & vbTab & "Installed: " & sDateValue
End If
End If
sTmp = sTmp & sValue & vbcrlf
cnt = cnt + 1
End If
Next
sTmp = BubbleSort(sTmp)
GetAddRemove = "INSTALLED SOFTWARE (" & cnt & ") - " & sCompName & _
" - " & Now() & vbcrlf & vbcrlf & sTmp
End Function
Function BubbleSort(sTmp)
'cheapo bubble sort
Dim aTmp, i, j, temp
aTmp = Split(sTmp, vbcrlf)
For i = UBound(aTmp) - 1 To 0 Step -1
For j = 0 to i - 1
If LCase(aTmp(j)) > LCase(aTmp(j+1)) Then
temp = aTmp(j + 1)
aTmp(j + 1) = aTmp(j)
aTmp(j) = temp
End if
Next
Next
BubbleSort = Join(aTmp, vbcrlf)
End Function
Function GetProbedID(sComp)
Dim objWMIService, colItems, objItem
Set objWMIService = GetObject("winmgmts:\\" & sComp & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select SystemName from " & _
"Win32_NetworkAdapter",,48)
For Each objItem in colItems
GetProbedID = objItem.SystemName
Next
End Function
Function GetDTFileName()
dim sNow, sMth, sDay, sYr, sHr, sMin, sSec
sNow = Now
sMth = Right("0" & Month(sNow), 2)
sDay = Right("0" & Day(sNow), 2)
sYr = Right("00" & Year(sNow), 4)
sHr = Right("0" & Hour(sNow), 2)
sMin = Right("0" & Minute(sNow), 2)
sSec = Right("0" & Second(sNow), 2)
GetDTFileName = sMth & sDay & sYr & "_" & sHr & sMin & sSec
End Function
Function WriteFile(sData, sFileName)
Dim fso, OutFile, bWrite
bWrite = True
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set OutFile = fso.OpenTextFile(sFileName, 2, True)
'Possibly need a prompt to close the file and one recursion attempt.
If Err = 70 Then
Wscript.Echo "Could not write to file " & sFileName & ", results " & _
"not saved." & vbcrlf & vbcrlf & "This is probably " & _
"because the file is already open."
bWrite = False
ElseIf Err Then
WScript.Echo err & vbcrlf & err.description
bWrite = False
End If
On Error GoTo 0
If bWrite Then
OutFile.Close
OutFile.WriteLine(sData)-----error at this line

End If
Set fso = Nothing
Set OutFile = Nothing
WriteFile = bWrite
End Function

Answered 12/16/2009 by: acbabu
Orange Belt

Please log in to comment
0
How did I miss this? I have forgone using the CODE tag in order to highlight your error:

If bWrite Then
OutFile.Close
OutFile.WriteLine(sData)
End If

P R E T T Y tricky to write to a file which you just closed....
Answered 12/17/2009 by: VBScab
Red Belt

Please log in to comment
0
Thanks VBscab for helping me
Answered 12/17/2009 by: acbabu
Orange Belt

Please log in to comment
Answer this question or Comment on this question for clarity