System Administration Scripting

2007年3月26日星期一

VBScript Change Local Admin Password with Excel File

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
("E:\PCandUsers.xls")

objExcel.visible = True
objExcel.DisplayAlerts = False

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""

On Error Resume Next

If NOT objExcel.Cells(intRow,4).Value = "OK" Then

strComputer = objExcel.Cells(intRow,1).Value

strObjUser = "WinNT://" & strComputer & "/ESPRIT,user"
Set objUser = GetObject(strObjUser)

If Err.Number = 0 Then
WScript.Echo Space(3) & strComputer & " is online. . ."
strPasswd = objExcel.Cells(intRow,2).Value
objUser.SetPassword strPasswd
objExcel.Cells(intRow,4).Value = "OK"
Else
WScript.Echo Space(3) & strComputer & " is not online. . ."
objExcel.Cells(intRow,4).Value = "NOK"
End If

End If

intRow = intRow + 1
Loop

objWorkbook.SaveAs "E:\LocalAdminPwd.xls"

objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing

Bookmark this post:
Ma.gnolia DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google


0 评论:

©2007 LastUpdated : 09/01/2024 10:03:43