Question on Return value of objOperatingSystem.name

Author Message
CUMCNate

  • Total Posts : 8
  • Scores: 0
  • Reward points : 0
  • Joined: 10/25/2011
  • Status: offline
Question on Return value of objOperatingSystem.name Friday, December 02, 2011 3:10 AM (permalink)
0
Hello all,
 
I created a VBS script that we could have our Desktop team utilize for gathering PC information for documentation purposes.  Everything works just the way I wanted it to, except there's one part that bugs me. 
 
When I display in objOperatingSystem.Name in a Msgbox it gives me the correct OS, but it adds |C:\WINDOWS|\Device\harddisk0\Parition1 at the end.  Is there a way to remove this extra information from being added?  Any help would be appreciated as I've looked around and haven't really found others wanting to do the similar thing.
 
My Script for Collecting Computer Information and displaying it in a msgbox format for a Tech.
 
 
Option Explicit
 
Dim strComputer, strOSName, strOSVersion, strServicePack, strHostName, strManufacturer, strModel, strRAM, strProcessor, strCPUManufacturer, strMACAddress
Dim objWMIService, objOperatingSystem, objComputer, objItem, colSettingsOS, colSettingsSys, colSettingsCPU, colItems, WShNetwork, wmiQuery, intRamMB, colComputer
Dim strintRAM, strData, objMACAddress, i
 
'Set Variables
strComputer = "."
 
' Gather system information via WMI
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettingsOS = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem") ' Query OperatingSystem component
For Each objOperatingSystem in colSettingsOS 
 strOSName = "OS Name: " & objOperatingSystem.Name
 strOSVersion = "OS Version: " & objOperatingSystem.Version
 strServicePack = "Current ServicePack: " & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion
Next
Set colSettingsSys = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettingsSys
     strHostName = "Computer Name: " & objComputer.Name
     strManufacturer = "Computer Manufacturer: " & objComputer.Manufacturer
     strModel = "Computer Model: " & objComputer.Model
     strRAM = "Memory in Computer: " & int((objComputer.TotalPhysicalMemory) /1048576)+1 & intRamMB & " MB"  
 
 Next
 
Set colItems = objWMIService.ExecQuery _
   ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
        strData = strData & "Description: " & objItem.Description & vbcrlf
   If Not IsNull(objItem.IPAddress) Then
      For i = 0 To UBound(objItem.IPAddress)
         strData = strData & "IP address: " & objItem.IPAddress(i) & vbcrlf
      Next
   End If
        strData = strData & "Adapter MAC: " & objItem.MACAddress & vbcrlf & vbcrlf
Next
Set colSettingsCPU = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colSettingsCPU
 strCPUManufacturer = "CPU Manufacturer: " & objItem.Manufacturer
 strProcessor = "CPU Model: " & objItem.Name
Next
 
MsgBox strOSName & vbLf & strServicePack & vbLf & strHostName & vbLf & strManufacturer & vbLf & strModel & vbLf & strRam & vbLf & strCPUManufacturer & vbLf & strProcessor & vbLf & vbLf & (strData), vbOkOnly, "Description Here for MessageBox Header"
 
Wscript.Quit(0)
 
#1
    59cobalt

    • Total Posts : 979
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Question on Return value of objOperatingSystem.name Friday, December 02, 2011 9:26 AM (permalink)
    0
    CUMCNate
    I created a VBS script that we could have our Desktop team utilize for gathering PC information for documentation purposes.  Everything works just the way I wanted it to, except there's one part that bugs me.

    When I display in objOperatingSystem.Name in a Msgbox it gives me the correct OS, but it adds |C:\WINDOWS|\Device\harddisk0\Parition1 at the end.  Is there a way to remove this extra information from being added?
    Use objOperatingSystem.Caption instead.

    CUMCNate
    My Script for Collecting Computer Information and displaying it in a msgbox format for a Tech.
    If the script is for technicians, then I'd suggest to use WScript.Echo instead of MsgBox(). That way a technician can run the script with cscript.exe instead of wscript.exe to get the information printed on the commandline, where he can mark/copy the text.
     
    #2
      CUMCNate

      • Total Posts : 8
      • Scores: 0
      • Reward points : 0
      • Joined: 10/25/2011
      • Status: offline
      Re:Question on Return value of objOperatingSystem.name Friday, December 02, 2011 9:31 AM (permalink)
      0
      Thanks, that worked exactly like I was searching for.
       
      What's the difference between objOperatingSystem.Name and .Caption in terms of what it shows you?
       
       
       
      #3
        59cobalt

        • Total Posts : 979
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Question on Return value of objOperatingSystem.name Friday, December 02, 2011 10:02 AM (permalink)
        0
        .Name includes the paths of %SystemRoot% folder and system volume, while .Caption does not.
        <message edited by 59cobalt on Friday, December 02, 2011 10:10 AM>
         
        #4

          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