@ECHO OFF :: Check Windows version (XP Pro or later) IF NOT "%OS%"=="Windows_NT" GOTO Syntax SETLOCAL VER | FIND "Windows NT" >NUL && GOTO Syntax VER | FIND "Windows 2000" >NUL && GOTO Syntax :: Check command line argument IF "%~1"=="" GOTO Syntax IF NOT "%~2"=="" GOTO Syntax ECHO."%~1" | FINDSTR /R /C:"[^\\]\\[^\\]" >NUL || GOTO Syntax ECHO."%~1" | FINDSTR /R /C:"[/?]" >NUL && GOTO Syntax FOR /F "tokens=1,2 delims=\" %%A IN ("%~1") DO ( SET Computer=%%~A SET User=%%~B ) IF NOT DEFINED User GOTO Syntax ECHO Checking current password expiration setting: WMIC.EXE /Node:%Computer% Path Win32_UserAccount Where Name="%User%" Get Name,PasswordExpires /Format:List | FIND "=" ECHO. ECHO Setting password to never expire: WMIC.EXE /Node:%Computer% Path Win32_UserAccount Where Name="%User%" Set PasswordExpires="FALSE" ECHO. ECHO Checking new password expiration setting: WMIC.EXE /Node:%Computer% Path Win32_UserAccount Where Name="%User%" Get Name,PasswordExpires /Format:List | FIND "=" ENDLOCAL GOTO:EOF :Syntax ECHO. ECHO PwdNoExp.bat, Version 1.00 for Windows XP and later ECHO Set a user's password to never expire ECHO. ECHO Usage: PWDNOEXP Computer\UserID ECHO. ECHO Notes: For local accounts only, do not use for domain accounts. ECHO Requires WMIC, which is a native command in Windows XP ECHO Professional, Windows Vista and Windows Server 2003/2008. ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com IF "%OS%"=="Windows_NT" ENDLOCAL