Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Easiest VBSCRIPT question of the day  (Read 4348 times)

0 Members and 1 Guest are viewing this topic.

Blue

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    Easiest VBSCRIPT question of the day
    « on: August 02, 2017, 08:14:23 AM »
    I have the following vbscript

    Code: [Select]
    ' VBScript to Display ComputerName

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    '
    WScript.Echo ("This computer is...         "& WshNetwork.ComputerName & vbCrLf & vbCrLf & _
                  "Active user is...                " & WshNetwork.username)

    I want to add OS name to my script. I have found these two "ways":
      wmic os get caption
      (gwmi win32_operatingsystem).caption
    but I don't know "OO" or VBS scripting so I don't know what to do.

    TIA

    Salmon Trout

    • Guest
    Re: Easiest VBSCRIPT question of the day
    « Reply #1 on: August 02, 2017, 10:38:02 AM »

    Blue

      Topic Starter


      Rookie

      • Experience: Experienced
      • OS: Windows 7
      Re: Easiest VBSCRIPT question of the day
      « Reply #2 on: August 02, 2017, 11:04:57 AM »
      I was able to get a working answer from the link provided (above). I had done many searches, but I didn't know what to search for.

      Problem SOLVED

      THANK YOU

      Salmon Trout

      • Guest
      Re: Easiest VBSCRIPT question of the day
      « Reply #3 on: August 02, 2017, 11:14:47 AM »
      This is the bare minimum you need
      Code: [Select]
      Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
      Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
       For Each os in oss
           Wscript.Echo "Caption: " & os.Caption
       Next