I have written a VBScript for you to do this. Please use with caution as it WILL delete the folder if its found (providing you have permission to)
For the moment i commented out the line that does the actual delete. Run it to see
A: It works
B: You get the results you expect
Read the descriptions in the code i put to help you
Hope it helps
Copy the whole code to a notepad and save as a .vbs file run from a command window CScript scriptname.vbs
PS don't forget to Uncomment the delete line when you are ready to delete.
Code:
' Deletes the profile of a user found on
' each computer in the file list. We Get
' asked which user to look for and
' deletes it if found. To run this script
' Open command window and type:
' CScript scriptname.vbs
Dim objFSO, wshShell
Dim strList, strUser, strProfilePath,strFile
Dim strComputerList, arrComputers, strComputer
Dim colFolder, oFolder
Const ForReading = 1
' #### Change these 2 to suit your needs #### '
' Profile Path
strProfilePath = "\C$\Documents and Settings\"
' File with list of computers in it (1 per line)
strFile = "C:\ComputerList.txt"
' #### This bit will ask you which user to look for #### '
strUser = InputBox("Enter the User to delete the profile of", "UserName")
If strUser = "" Then
WScript.Quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objList = objFSO.OpenTextFile(strFile, ForReading, False)
strComputerList = objList.ReadAll
objList.Close
' #### We will now go through each computer from the list #### '
arrComputers = Split(strComputerList, vbNewLine)
For Each strComputer In arrComputers
If strComputer = "" Then
WScript.Quit
End If
Set colFolder = objFSO.GetFolder("\\" & strComputer & strProfilePath)
For Each oFolder In colFolder.SubFolders
WScript.Echo oFolder.name
If LCase(oFolder.Name) = LCase(strUser) Then
WScript.Echo "MATCH"
'objFSO.DeleteFolder("\\" & strComputer & strProfilePath & strUser)
WScript.Quit
End If
Next
Next
WScript.Echo "Completed!"
Bookmarks