首页 » VBS脚本 » 设置windows账户密码永不过期组策略密码最长使用天

设置windows账户密码永不过期组策略密码最长使用天

此脚本可以设置windows账户不过期,密码永不过期,也能修改组策略中密码使用最长天数。

secedit /configure /cfg C:\1.inf /db secedit.sdb
/db 是个临时数据库文件随便指定
/cfg 配置文件必须是正确的,如果不知道先效验
/quiet 表示安静模式
/verbose 更详尽的日志信息
/log 回显日志位置
/overwrite 覆盖

Dim Computer : Computer=getpcname()
Function getpcname()
	On Error Resume Next
	Err.Clear
	Dim obj:Set obj=CreateObject("wscript.network")
	getpcname=obj.ComputerName
	Set obj=Nothing
	If Err.Number<>0 Then 
		WScript.Echo "无法获取计算机名.终止."
		WScript.Quit
	End If
End Function
 
Sub SetGPO_PassExpire(intday)
	Dim folder_,cfgfile,dbfile,txtbody,wsh,fso,f
	folder_="C:\windows\temp"
	cfgfile = folder_ & "\sec1.inf"
	dbfile  = folder_ & "\sec1.sdb"
	txtbody = "[version]" &vbCrLf&"signature=""$CHICAGO$"""&vbcrlf&"DriverVer=10/01/2002,5.2.3790.0"&vbCrLf&vbcrlf&"[Profile Description]"&vbCrLf&"%SCEProfileDescription%"&vbCrLf&vbcrlf&"[System Access]"&vbCrLf&"MaximumPasswordAge=" & intday
	Set wsh = CreateObject("wscript.Shell")
	Set fso = CreateObject("scripting.filesystemobject")
	Set f=fso.OpenTextFile(cfgfile,2,True)
	f.Write(txtbody) : f.Close
	cmdstr="cmd /c secedit /configure /cfg " & cfgfile & " /db " & dbfile & " /quiet"
	wsh.Run cmdstr,1,True
	Set wsh=Nothing
	fso.DeleteFile cfgfile
	fso.DeleteFile dbfile
	Set fso=Nothing
End Sub
 
Sub setUser_PassExpire(strUser)
	On Error Resume Next
	Dim userObj,Flags
	Set userObj = Getobject("WinNT://" & Computer & "/" & strUser & ",user")
	Flags = userObj.Get("UserFlags")
	userObj.PasswordExpired=0
	userObj.put "Userflags",Flags Or &H10000
	userObj.Accountdisabled = False
	userObj.AccountExpirationDate="1970-1-1"
	userObj.IsAccountLocked=False
	userObj.Setinfo
	Set userObj=Nothing
End Sub

转发到新浪微博 转发到新浪微博

目前这篇文章有1条评论(Rss)

  1. Bankruptcy Copies | #1
    05/17/2012 at 08:49

    Early to bed and early to rise make a man healthy wealthy and wise.

我要评论