Jump to content
Sign in to follow this  
vcent

Get domain

Recommended Posts

vcent

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.

Share this post


Link to post
Share on other sites
Danny35d

$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

Share this post


Link to post
Share on other sites
ibroadbent

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.