Using Netdom and Reg from the
Using Netdom from a
and the freeware Reg, I have created a batch file for a Windows 2000 domain.The syntax is LastUser <DomainName>, where LastUser.bat contains:
@echo off cls if "%1""" goto nodom set dom=%1 if exist output.txt del output.txt if exist temp.txt del temp.txt for /f "Skip=2 Tokens=1*" %%i in ('netdom query /domain:%dom% workstation') do call :parse %%i sort <temp.txt>output.txt del temp.txt goto end :parse if "%1"
"The" goto end set computer=%1 for /f "Tokens=2" %%i in ('reg -ListValue "\\%1\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName"') do set wsdom=%%i if /i "%wsdom%"=="%dom%" goto user set usr=None :pipe set computer=%computer% ! set computer=%computer:~0,25% @echo %computer% %usr% >> temp.txt goto end :user for /f "Tokens=2" %%i in ('reg -ListValue "\\%1\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName"') do set usr=%%i goto pipe :nodom echo Specify the target domain on the command line echo EXAMPLE: lastuser MyDomainName echo. :end
0 comments
Hide comments