Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please show vbscript newbie how to pass parameters to shell 1

Status
Not open for further replies.

richardv

MIS
Oct 5, 2002
22
0
0
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
 
oWshShell.Run "net user " & sUserID & " " & sPassword,,True


Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top