VBScript to delete profile remotly

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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"
.



Relevant Pages

  • Re: Script: Remote shutdown of all domain computers
    ... If the computers are Windows ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... Because i can't realy script in VB, i am unable to create my own scripts. ... Public Function AllComputersAs String() ...
    (microsoft.public.windows.server.scripting)
  • Re: Remote Shutdown Batch Issue
    ... I initially wanted to have a scheduled task run on my server ... > calls on a list.txt of computers. ... > be easier to centralize the shutdown process on one server, ... Dim WshX ...
    (microsoft.public.windows.server.scripting)
  • Re: Annoying Problem - Subscript out of range
    ... only occurs on two computers, which I have limited access to. ... fname was still defined when I checked it during debugging and I never ... Dim OpenFilename As Variant ... Dim fname, officename As String ...
    (microsoft.public.excel.programming)
  • Send mail from excel - Copy/paste unformatted values and error
    ... Thanks so much, Brice ... When they try on their computers they receive an script error message. ... Dim fso As Object ... Set rng = Nothing ...
    (microsoft.public.excel.programming)
  • Re: BackgroundWorker thread locking UI
    ... Protected Overrides Sub OnLoad ... tsStatus.Text = "Loading Computers. ... Private Sub bgLoadComputers_DoWork(ByVal sender As System.Object, ... Dim dtComputers As New DataTable ...
    (microsoft.public.dotnet.languages.vb)