VBScript for deleting profile remotly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi , I wrote this VBScript which it is suppose to delete profile remotly, but
it doesn't. Can some one help? Thank you

Option Explicit

Dim Computers, arrComputers, PC
Dim Users, arrUsers, Usr
Dim objComputer, objUser
Dim bDelete, intResult

' Users that will not get deleted
Users = "Administrator,vg38189,wau9517"

' Computers
Computers = "d_4dj0q11"

' Ask the administrator
intResult = MsgBox("Are you sure you want to clear all profiles?", vbYesNo +
vbQuestion, "Warning")
If intResult = vbYes Then

arrComputers = Split(Computers,",")
arrUsers = Split(Users,",")

' Search through all computers
For Each PC in arrComputers

' Get a list of the users on the current computer
Set objComputer = GetObject("C://" & PC)
objComputer.Filter = Array("User")

' Search through the list of users on the current computer
For Each objUser In objComputer

bDelete = True

' Check if the current user should not be deleted
For Each Usr In arrUsers
If Usr = objUser.Name Then
bDelete = False
End If
Next

If bDelete Then
' Delete the user
' WScript.Echo "Deleting: \\" & PC & "\" & objUser.Name
objComputer.Delete "user", objUser.Name
End If

Next

Next

WScript.Echo "Done"
 
Back
Top