Jump to content

Get domain


Recommended Posts

Hi,

I want to get the windows server domain.

I search thr the help and got @logonDNSdomain and @logondomain

However the above only gave the user login domain.

What I need is the computer domain.

thanks.

Link to comment
Share on other sites

$ComputerDomain = _DomainComputerBelongs()
MsgBox(0 , @LogonDomain , 'Domain: ' & $ComputerDomain)

Func _DomainComputerBelongs($strComputer = "localhost")
   ; Generated by AutoIt Scriptomatic
    $Domain = ''
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    If Not IsObj($objWMIService) Then Return SetError(1, 0, '')
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
                                            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
        For $objItem In $colItems
            $Domain = $objItem.Domain
        Next
    Endif
    Return $Domain
EndFunc

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

  • 2 years later...

Hi,

I want to get the windows server domain.

I search thr the help and got @logonDNSdomain and @logondomain

However the above only gave the user login domain.

What I need is the computer domain.

thanks.

This will return the name of the Domain:

$Domain = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Domain")

It returns null if the PC is a Workgroup member.

It also reports the domain even when logging in to a local account on the PC.

ibroadbent

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...