richardv
MIS
- Oct 5, 2002
- 22
I am trying to change the the users' password [from a file] using the "net user" shell command for a WinNT4.0 server. I get hung up at this point, [oWshShell.Run "net user sUserID sPassword",,True] on the script. I was able to get it going using SendKeys...but there must be a more elegant way of doing it. I also saw examples using ADSI, but it seemed as if you need the old password to give it a new password. Also if there is a better way of doing it, don't hesitate to advise. Here is what I have so far.
Dim oWshShell, oFSO, oStream, sLine, sLine2, array, sUserID, sPassword
set oWshShell = CreateObject("WScript.Shell"
Set oFSO = CreateObject("Scripting.FileSystemObject"
Set oStream = oFSO.OpenTextFile("q:\vbscript\password1.txt", 1)
Do Until oStream.AtEndOfStream
sLine = oStream.ReadLine
sLine2 = Trim(sLine)
array = Split(sLine2, "/", 2)
sUserID = array(0)
If UBound(array) >= 1 Then
sPassword = array(1)
Else
sPassword = "No Password specified"
End If
oWshShell.Run "net user sUserID sPassword",,True
Loop
Set oFSO = Nothing
Set oStream = Nothing
Set oWshShell = Nothing
Dim oWshShell, oFSO, oStream, sLine, sLine2, array, sUserID, sPassword
set oWshShell = CreateObject("WScript.Shell"
Set oFSO = CreateObject("Scripting.FileSystemObject"
Set oStream = oFSO.OpenTextFile("q:\vbscript\password1.txt", 1)
Do Until oStream.AtEndOfStream
sLine = oStream.ReadLine
sLine2 = Trim(sLine)
array = Split(sLine2, "/", 2)
sUserID = array(0)
If UBound(array) >= 1 Then
sPassword = array(1)
Else
sPassword = "No Password specified"
End If
oWshShell.Run "net user sUserID sPassword",,True
Loop
Set oFSO = Nothing
Set oStream = Nothing
Set oWshShell = Nothing