FOR /F "TOKENS=2 DELIMS==" %%A IN ('"WMIC /NAMESPACE:\\ROOT\CIMV2 PATH Win32_UserAccount GET Name /VALUE"') DO (
CALL WMIC /NAMESPACE:\\ROOT\CIMV2 PATH Win32_UserAccount WHERE Name='%%A' SET PasswordExpires=FALSE
)
powershell -ep bypass -nop -c "Set-CimInstance -Query 'Select * from Win32_UserAccount' -Property @{PasswordExpires=0}"
For example I would be one of those. Unfortunately I have always been forced to use a password, otherwise file sharing between different machines in my network won't (apparently) work (ok this might even be a good thing in theory...)I just wanted to briefly add, that you can also leave the password blank to remove it entirely. I mention this, because it's not intuitive during the Windows Setup process, when the password screen comes up it's worded in a way that sounds like you must enter a password, but if you click next it'll skip it.
I've seen a lot of people asking about the password expiration setting, so I figured at least some of those people are wanting no password, but are assuming it's not possible and so they ask for no expiration instead.
Though it's not generally advised, some users will disable SMB password auth and allow anonymous logons.For example I would be one of those. Unfortunately I have always been forced to use a password, otherwise file sharing between different machines in my network won't (apparently) work (ok this might even be a good thing in theory...)
Indeed, I prefer to keep this minimal security level, at the cost of having to insert a password at every bootThough it's not generally advised, some users will disable SMB password auth and allow anonymous logons.
Have you tried the command:net accounts /maxpwage:unlimited DOES NOT WORK here, not even if invoked live from the command prompt.
As a fact, if you open lusrmgr.msc you will see that "Password never expires" remains UNCHECKED.
The proper command seems rather (I found it googling):
wmic UserAccount set PasswordExpires=False
I have added it in PostSetup, post-logon (with >NIL to avoid a shell opening) and on boot with lusrmgr.msc I can see the "Password never expires" box correctly *checked* (this at least with Win 10 22H2)