Help with vbscript to html output

Author Message
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)
0
[Helpful answer received] / [List Solutions Only]
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
 
#1
    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)
    4
    [This post was marked as helpful]
    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.
     
    #2
      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)
      0
      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
       
       
       
      #3
        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)
        0
        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
         
        #4
          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)
          5
          [This post was marked as helpful]
          Check if your query actually returns a result set.
          WScript.Echo TypeName(colSoftware)
          WScript.Echo colSoftware.Count

           
          #5
            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)
            0
            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
             
            #6
              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)
              5
              [This post was marked as helpful]
              I normally use the .ComputerName property of the WshNetwork object to get the hostname. There are numerous other ways, though.
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9