Using NETDOM.EXE and REG.EXE, from the Support / Tools folder of your O/S CD-ROM, or built into your O/S, I have scripted IsDomMbr.bat to determine if the computer you are logged on to is a member of a specified domain.
The syntax for using IsDomMbr.bat is:
IsDomMbr DomainName User Password Answer
Where:
DomainName is the NetBIOS or DNS domain name. User is a domain administrator account name. Password is the domain password of the User account. Answer is a call directed environment variable that will be set to: Y - if the computer is a member of the specific DomainName, or N - if the computer is NOT a member.IsDomMbr.bat contains:
@echo off if \{%4\}==\{\} @echo Syntax IsDomMbr DomainName User Password Answer&goto :EOF setlocal set domain=%1 set user=%2 set pwd=%3 set Answer=N set nd=netdom query /domain:%domain% /UserD:%user% /PasswordD:%pwd% set rq=reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName for /f "Tokens=2*" %%r in ('%rq%^|find "REG_SZ"') do ( set pn=%%s ) set wrk=%pn:server=% if "%wrk%" EQU "%pn%" goto iswstn call :netd DC if "%Answer%" EQU "Y" goto Finish call :netd SERVER goto Finish :iswstn call :netd WORKSTATION goto Finish :netd for /f "Tokens=*" %%a in ('%nd% %1^|findstr /i /l /c:"%COMPUTERNAME%"') do ( set Answer=Y ) goto :EOF :Finish endlocal&set %4=%Answer%
0 comments
Hide comments