Rob van der Woude's Scripting Pages

VBScript Scripting Techniques > Network > Names

Retrieving Names

In this section I'll show you how to retrieve user names, computer names and domain names (user domains, computer domains, ...) and related properties using various techniques.

I'll also try to list all requirements for each technique: OS version, Active Directory/NT domain/workgroup, stand-alone VBScript vs. HTA, and WMI or client software.

So, depending on your environment, you may need to combine several techniques to cover all OS versions and all possible configurations.

To test if any of these techniques work in your environment, I also created a script demonstrating each of these techniques (download the ZIPped source here).

 

  1. User Name
    1. Environment Variable
    2. WshNetwork
    3. ADSI (WinNTSystemInfo)
    4. ADSI (ADSystemInfo)
    5. WMI (Win32_ComputerSystem)
    6. System Scripting Runtime
     
  2. Computer Name
    1. Environment Variable
    2. WshNetwork
    3. SHGINA.DLL (Shell.LocalMachine)
    4. ADSI (WinNTSystemInfo)
    5. ADSI (ADSystemInfo)
    6. WMI (Win32_ComputerSystem)
    7. System Scripting Runtime
     
  3. Host Names
    1. Registry (WSH Shell)
    2. Registry (WMI StdRegProv)
    3. System Scripting Runtime
     
  4. Computer Domain or Workgroup Name
    1. WMI (Win32_ComputerSystem)
    2. WMI (Win32_NTDomain)
    3. System Scripting Runtime
     
  5. User Domain Name
    1. Environment Variable
    2. WshNetwork
    3. ADSI (WinNTSystemInfo)
    4. ADSI (ADSystemInfo)
     

page last modified: 2016-09-19; loaded in 0.0014 seconds