(view source code of getuserdetails.bat as plain text)
@ECHO OFF
IF "%~1"=="" (
cls
echo "Please enter the username you want to check!"
pause
goto _end
)Set UserToCheck=%~1
echo Getting details for user %UserToCheck%...
rem Getting and saving the userdata to extract all details from this fileNET USER %UserToCheck% /DOMAIN > userinfo.txt
Set Delimiter=!
Set UserName=
Set FullName=
Set Comment=
Set AccountActive=0
Set AccountExpires=
Set PwdLastSet=
Set PwdExpires=
Set PwdChangeable=
Set PwdRequired=
Set UserMayChangePwd=0
Set WrkStatAllowed=
Set LogonScript=
Set UserProfile=
Set HomeDir=
Set LastLogon=
Set LogonHoursAllowed=
rem User namerem parse userinfo.txt for the string "User name" and store this line in %UserName% rem to extract just the content, we cut the first 29 characters of the lineFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "User name"') DO SET UserName=%%A
SET UserName=%UserName:~29,100%
rem Full NameFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Full Name"') DO SET FullName=%%A
SET FullName=%FullName:~29,100%
rem CommentFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Comment"') DO SET Comment=%%A
SET Comment=%Comment:~29,100%
rem Account activeFIND "Account active Yes" userinfo.txt >NUL
IF NOT ERRORLEVEL 1 set AccountActive=1
rem Account expiresFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Account expires"') DO SET AccountExpires=%%A
SET AccountExpires=%AccountExpires:~29,100%
rem Password last setFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Password last set"') DO SET PwdLastSet=%%A
SET PwdLastSet=%PwdLastSet:~29,100%
rem Password expiresFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Password expires"') DO SET PwdExpires=%%A
SET PwdExpires=%PwdExpires:~29,100%
rem Password changeableFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Password changeable"') DO SET PwdChangeable=%%A
SET PwdChangeable=%PwdChangeable:~29,100%
rem Password requiredFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Password required"') DO SET PwdRequired=%%A
SET PwdRequired=%PwdRequired:~29,100%
rem User may change passwordFIND "User may change password Yes" userinfo.txt >NUL
IF NOT ERRORLEVEL 1 set UserMayChangePwd=1
rem Workstations allowedFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Workstations allowed"') DO SET WrkStatAllowed=%%A
SET WrkStatAllowed=%WrkStatAllowed:~29,100%
rem Logon scriptFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Logon script"') DO SET LogonScript=%%A
SET LogonScript=%LogonScript:~29,100%
rem User profileFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "User profile"') DO SET UserProfile=%%A
SET UserProfile=%UserProfile:~29,100%
rem Home directoryFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Home directory"') DO SET HomeDir=%%A
SET HomeDir=%HomeDir:~29,100%
rem Last logonFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Last logon"') DO SET LastLogon=%%A
SET LastLogon=%LastLogon:~29,100%
rem Logon hours allowedFOR /F "delims=" %%A IN ('type userinfo.txt ^| FIND "Logon hours allowed"') DO SET LogonHoursAllowed=%%A
SET LogonHoursAllowed=%LogonHoursAllowed:~29,100%
rem === Output ===rem ==============IF NOT EXIST UserDetailList.txt (
echo UserName %Delimiter% FullName %Delimiter% Comment %Delimiter% AccountActive %Delimiter% AccountExpires %Delimiter% PwdLastSet %Delimiter% PwdExpires %Delimiter% PwdChangeable %Delimiter% PwdRequired %Delimiter% UserMayChangePwd %Delimiter% WrkStatAllowed %Delimiter% LogonScript %Delimiter% UserProfile %Delimiter% HomeDir %Delimiter% LastLogon %Delimiter% LogonHoursAllowed > UserDetailList.txt
)echo %UserName%%Delimiter%%FullName%%Delimiter%%Comment%%Delimiter%%AccountActive%%Delimiter%%AccountExpires%%Delimiter%%PwdLastSet%%Delimiter%%PwdExpires%%Delimiter%%PwdChangeable%%Delimiter%%PwdRequired%%Delimiter%%UserMayChangePwd%%Delimiter%%WrkStatAllowed%%Delimiter%%LogonScript%%Delimiter%%UserProfile%%Delimiter%%HomeDir%%Delimiter%%LastLogon%%Delimiter%%LogonHoursAllowed% >> UserDetailList.txt
echo done
exit
:_endpage last modified: 2025-10-11; loaded in 0.0062 seconds