Re: to get the remote machine's domain or workgroup name

Discussion in 'Scripting' started by Clay Calvert, Oct 16, 2004.

  1. Clay Calvert

    Clay Calvert Guest

    The following is a one line batch file.

    for /f %%a in ('nbtstat -a SERVERname ^| find "<00>" ^| find "GROUP"')
    do set DomGroup=%%a

    Clay Calvert

    Replace "W" with "L"
    Clay Calvert, Oct 16, 2004
    1. Advertisements

  2. Clay Calvert

    Frank Guest

    Thanks Clay,

    By using nbtstat -a to retrieve remote machine's netbois info, and filter
    "00" and "group", but how do I know whether it is a workgroup or domain?

    Thanks again

    tools like psinfo.exe, psexec.exe, but I cannot get the the server's
    domain/workgroup name. How can I do that in a batch file, or vbscript or any
    other tools?
    Frank, Oct 17, 2004
    1. Advertisements

  3. Clay Calvert

    Frank Guest

    Hi, I got the vbs to do so: a argument is passed to the vbs.

    strComputer = Wscript.Arguments(0)

    If Wscript.Arguments.Count <> 1 Then
    WScript.Echo "Syntax Error. Correct syntax is:"
    Wscript.Echo "cscript ComputerRole.vbs computername"
    End If

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    Set colComputers = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
    For Each objComputer in colComputers
    Select Case objComputer.DomainRole
    Case 0
    strComputerRole = "Standalone Workstation"
    Case 1
    strComputerRole = "Member Workstation"
    Case 2
    strComputerRole = "Standalone Server"
    Case 3
    strComputerRole = "Member Server"
    Case 4
    strComputerRole = "Backup Domain Controller"
    Case 5
    strComputerRole = "Primary Domain Controller"
    End Select

    WScript.Echo "System Name: " & objComputer.Name
    Wscript.Echo "Domain/Workgroup: " & objComputer.Domain
    Wscript.Echo "Computer Role: " &strComputerRole
    Frank, Oct 17, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.