0

我有以下代码“应该”勾选框以在下次登录时更改本地用户密码,但我不断收到错误。

该帐户已在本地创建并在服务器上。

请提供任何帮助。

由于我们环境中的服务器较旧,我必须在 vbscript 而不是 powershell 中执行此操作。

代码:

' get computer name
Set oWshNet = CreateObject("WScript.Network" )
sComputerName = oWshNet.ComputerName

'Set Account Testuser Password Expired parameter
Set objUser = GetObject("WinNT:// " & sComputerName & "/Testuser")
objUser.Put "PasswordExpired", 1
objUser.SetInfo

错误:

account.vbs(6, 1) (null): 未找到网络路径。

** * **编辑* ** * ** * ****

想通了:(感谢谷歌!)

Set oShell = CreateObject("WScript.Shell")
Const SUCCESS = 0

sUser = "TestUser"

' get the local computername with WScript.Network,
' or set sComputerName to a remote computer
Set oWshNet = CreateObject("WScript.Network")
sComputerName = oWshNet.ComputerName

Set oUser = GetObject("WinNT://" & sComputerName & "/" & sUser)

oUser.Put "PasswordExpired", 1
oUser.SetInfo

oShell.LogEvent SUCCESS, "Password Attribute Changed"
4

1 回答 1

0

谢谢。

答案是:

Set oShell = CreateObject("WScript.Shell") 
Const SUCCESS = 0 

sUser = "TestUser" 

' get the local computername with WScript.Network, 
' or set sComputerName to a remote computer 
Set oWshNet = CreateObject("WScript.Network") 
sComputerName = oWshNet.ComputerName 

Set oUser = GetObject("WinNT://" & sComputerName & "/" & sUser) 

oUser.Put "PasswordExpired", 1 
oUser.SetInfo 

oShell.LogEvent SUCCESS, "Password Attribute Changed" 
于 2012-04-13T13:25:43.917 回答