timassin
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 11/14/2011
-
Status: offline
|
Help with vbscript to html output
Monday, November 14, 2011 5:08 AM
( permalink)
Hello, I'm brand new to these forums. Thanks for taking a look at this problem with me, I'm trying to get this script to display the software from the current pc and covert it to html and save it to a location. So far this is what i currently have, Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}//./root/cimv2")
Set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product")
SET objFS = CreateObject ("Scripting.FileSystemObject")
SET objNewFile = objFS.CreateTextFile("htmloutput.htm")
objNewFile.WriteLine "<html>"
objNewFile.WriteLine "<head>"
objNewFile.WriteLine "<title>Software Report</title>"
objNewFile.WriteLine "</head>"
objNewFile.Writeline "<body>"
objNewFile.Writeline "<h1>Software Report -- Date: " & Now() & _
"</h1>" & vbCrlf
objNewFile.WriteLine "<table BORDER=1>"
For Each objSoftware In colSoftware
objNewFile.WriteLine "<tr>"
objNewFile.WriteLine _objSoftware
"<td>Software:</td><td>" & objSoftware.Name & "</td>"
objNewFile.WriteLine "<td>Executable Path:</td><td>" & _
objOperatingSystem.ExecutablePath & "</td>"
objNewFile.WriteLine "</tr>"
objNewFile.WriteLine "</table>"
objNewFile.WriteLine "</body>"
objNewFile.WriteLine "</html>"
objNewFile.Close I was able to edit some powershell code fairly easy to get this done but with all the security on our domain powershell is not a good option at the moment. Thats why I'd like to write it in vbscript the only problem is I'm not that familar with it. Any help would be greatly appreciated any additional info needed please ask. Thanks again, Tim
|
|
|
|
59cobalt
-
Total Posts
:
972
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: online
|
Re:Help with vbscript to html output
Monday, November 14, 2011 7:05 AM
( permalink)
timassin
objNewFile.WriteLine _objSoftware
"<td>Software:</td><td>" & objSoftware.Name & "</td>" Change "_objSoftware" into "_". timassin objNewFile.WriteLine "<td>Executable Path:</td><td>" & _ objOperatingSystem.ExecutablePath & "</td>"[/code] You don't have an object "objOperatingSystem", and the Win32_Product WMI class does not have a property "ExecutablePath". If anything else isn't working: please provide details.
|
|
|
|
timassin
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 11/14/2011
-
Status: offline
|
Re:Help with vbscript to html output
Tuesday, November 15, 2011 3:11 AM
( permalink)
Hey 67colbalt, Thanks for the reply, the only problem I'm having now is it error out on the last line last char. Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}//./root/cimv2")
Set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product")
SET objFS = CreateObject ("Scripting.FileSystemObject")
SET objNewFile = objFS.CreateTextFile("htmloutput.htm")
objNewFile.WriteLine "<html>"
objNewFile.WriteLine "<head>"
objNewFile.WriteLine "<title>Software Report</title>"
objNewFile.WriteLine "</head>"
objNewFile.Writeline "<body>"
objNewFile.Writeline "<h1>Software Report -- Date: " & Now() & _
"</h1>" & vbCrlf
objNewFile.WriteLine "<table BORDER=1>"
For Each objSoftware In colSoftware
objNewFile.WriteLine "<tr>"
objNewFile.WriteLine _
"<td>Software:</td><td>" & objSoftware.Name & "</td>"
objNewFile.WriteLine "</tr>"
objNewFile.WriteLine "</table>"
objNewFile.WriteLine "</body>"
objNewFile.WriteLine "</html>"
objNewFile.Close Thanks, Tim
|
|
|
|
timassin
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 11/14/2011
-
Status: offline
|
Re:Help with vbscript to html output
Tuesday, November 15, 2011 5:00 AM
( permalink)
I figured out why I was getting an error I fogot to add NEXT. The only problem now is that it only dispalys the Title it doesn't list all the software from win32 Product WMI. Any help would be appreciated. Thanks, Tim
|
|
|
|
59cobalt
-
Total Posts
:
972
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: online
|
Re:Help with vbscript to html output
Tuesday, November 15, 2011 10:24 AM
( permalink)
Check if your query actually returns a result set. WScript.Echo TypeName(colSoftware)
WScript.Echo colSoftware.Count
|
|
|
|
timassin
-
Total Posts
:
14
- Scores: 0
-
Reward points
:
0
- Joined: 11/14/2011
-
Status: offline
|
Re:Help with vbscript to html output
Wednesday, November 16, 2011 4:54 AM
( permalink)
Awsome thanks for all your help so far 59cobalt, the only thing I'm left with having some trouble is I want to save the file as the hostname of the computer it runs on and save it to a different location. Would you be able to assist? Set objWMIService = _
GetObject("winmgmts:{impersonationLevel=impersonate}//./root/cimv2")
Set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product")
SET objFS = CreateObject ("Scripting.FileSystemObject")
SET objNewFile = objFS.CreateTextFile("hostname.htm")
objNewFile.WriteLine "<html>"
objNewFile.WriteLine "<head>"
objNewFile.WriteLine "<title>Software Report</title>"
objNewFile.WriteLine "</head>"
objNewFile.Writeline "<body>"
objNewFile.Writeline "<h1>Software Report -- Date: " & Now() & _
"</h1>" & vbCrlf
objNewFile.WriteLine "<table BORDER=1>"
For Each objSoftware In colSoftware
objNewFile.WriteLine "<tr>"
objNewFile.WriteLine _
"<td>Software:</td><td>" & objSoftware.Name & "</td>"
objNewFile.WriteLine "</tr>"
NEXT
objNewFile.WriteLine "</table>"
objNewFile.WriteLine "</body>"
objNewFile.WriteLine "</html>"
objNewFile.Close Thanks again, Tim
|
|
|
|
59cobalt
-
Total Posts
:
972
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: online
|
Re:Help with vbscript to html output
Wednesday, November 16, 2011 9:36 AM
( permalink)
|
|
|
|