Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit[green]
'==========================================================================
'
' NAME: resetAdminPasswordsonPC.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE : 4/21/2004
' COPYRIGHT (C) 2004, All Rights Reserved
'
' COMMENT: Resets the local admin password on domain computers.
' Requires a list of workstation names called wslist.txt.
' MODIFICATIONS:
' 7/9/2006- Added event log code
'
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
' OF THIS CODE OR INFORMATION.
'
'==========================================================================[/green]
On Error Resume Next
Const EVENT_SUCCESS = 0
Dim WSHShell, oFSO, oFailureReport, oSuccessReport, oTextStream, oAdminID, RemotePC, strComputerName
Dim adminPassword
Set WSHShell = CreateObject("Wscript.Shell")
Set oFSO=CreateObject("Scripting.FileSystemObject")
If Not oFSO.FolderExists("c:\scripts\lists") Then
oFSO.CreateFolder("c:\scripts")
oFSO.CreateFolder("c:\scripts\lists")
End If
If oFSO.FileExists("c:\scripts\lists\failed.txt") Then
oFSO.DeleteFile("c:\scripts\lists\failed.txt")
End If
If oFSO.FileExists("c:\scripts\lists\success.txt") Then
oFSO.DeleteFile("c:\scripts\lists\success.txt")
End If
set oFailureReport=oFSO.createtextfile("c:\scripts\lists\failed.txt")
set oSuccessReport=oFSO.createtextfile("c:\scripts\lists\success.txt")
[green]
'open the data file[/green]
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
If Err Then
MsgBox vbTab & vbTab & "WSLIST.TXT Source File Required" & vbCrLf & "Create the file, place in the same directory as this script and try again."
WScript.Quit
End If
[green]
'make an array from the data file[/green]
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
[green]'close the data file[/green]
oTextStream.Close
For Each strComputername In RemotePC
[green] 'Goto the local Admin account of the machine[/green]
set oAdminID = GetObject("WinNT://" & strComputername & "/administrator,user")[green]
'Check for error and record in case of failed attempt
[/green] If Err Then
ReportError()
Err.Clear
Else
adminPassword = [red]"putnewpasswordhere"[/red]
oAdminID.SetPassword adminPassword
oAdminID.SetInfo
oSuccessReport.WriteLine strComputername & " Admin Password was reset."
End If
WSHShell.LogEvent EVENT_SUCCESS, _
"Admin password reset by a script from The Spider's Parlor. http://www.thespidersparlor.com/vbscript", "\\" & strComputername
Next
[green]
'Close all open files[/green]
oFailureReport.close
oSuccessReport.close
[green]
'Let us know its finished[/green]
msgbox "Done"
set oFSO = nothing
set oAdminID = Nothing
set oTextStream = nothing
set oSuccessReport = nothing
set oFailureReport = nothing
Sub ReportError()
oFailureReport.WriteLine strComputername & " could not be reset. Check that it is powered on." & Err.Number
End Sub