Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
April 18, 2006
To force a user to change their password at next logon, you could use the following VBScript:
Dim usrSet usr = GetObject("WinNT://NetBIOSDomainName/UserLogonName,user")usr.Put "PasswordExpired", CLng(1)usr.SetInfo
Where:
NetBIOSDomainName is the NetBIOS Domain Name, like JSIINC.UserLogonName is the user logon name, like Jerry.
NOTE: To clear the User must change password at next logon flag, change CLng(1) to CLng(0).
I have scripted MCPANL.bat to force a user to change their password at next logon.
The syntax for using MCPANL.bat is:
[Call] MCPANL NetBIOSDomainName UserLogonName
MCPANL.bat contains:
@echo offif {%2}=={} @echo Syntax: MCPANL NetBIOSDomainName UserLogonName&goto :EOFsetlocalset dom=%1set usr=%2if exist "%TEMP%MCPANL.VBS" goto [email protected] usr, objArguments>"%TEMP%MCPANL.VBS"@echo set objArguments = Wscript.Arguments>>"%TEMP%MCPANL.VBS"@echo dom=objArguments(0)>>"%TEMP%MCPANL.VBS"@echo un=objArguments(1)>>"%TEMP%MCPANL.VBS"@echo ldp = "WinNT://" ^& dom ^& "/" ^& un ^& ",user">>"%TEMP%MCPANL.VBS"@echo Set usr = GetObject(ldp)>>"%TEMP%MCPANL.VBS"@echo usr.Put "PasswordExpired", CLng(1)>>"%TEMP%MCPANL.VBS"@echo usr.SetInfo>>"%TEMP%MCPANL.VBS":doitcscript //nologo "%TEMP%MCPANL.VBS" %dom% %usr%endlocal
You May Also Like