Script Center > Scripting Forums > The Official Scripting Guys Forum! > [VBScript] I'm looking for a script that will delete a User Profile remoltely
Ask a questionAsk a question
 

Question[VBScript] I'm looking for a script that will delete a User Profile remoltely

  • Wednesday, July 01, 2009 4:27 PMEnfury Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello.

    I have a problem going on in my site. We had a virus outbreak, and it put the profile "cypscanner2" on every PC in my site. I got the virus removed from the original PC with the real user profile "cypscanner2" but now I need to remove the user profile "cypscanner2" from all of the other PCs in my site. So my question is, is there a VBscript I can run remotely to remove "cypscanner2" from 'C:\Documents and Settings"? I have virtually 0 scripting expierence so any and all help would be great.

    Thanks in advance.

    Enfury

All Replies

  • Thursday, July 02, 2009 4:18 AMNickHunyady Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Should be as simple as:

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFolder "C:\Documents and Settings\cypscanner2", True

    Or remotely:

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFolder "\\ServerName\C$\Documents and Settings\cypscanner2", True

  • Thursday, July 02, 2009 2:43 PMAbqBillModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Nick,

    Using the FileSystemObject object to delete a folder will delete the profile directory, but it won't delete its associated registry path:

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\user's SID

    There are also two other complications: 1. you can't delete a profile for a user that's logged on; and 2. the user might have logged off, but the profile might not be completely unloaded (see http://support.microsoft.com/kb/837115 ).

    In the meantime, I recommend 'uphclean' and the 'delprof.exe' found in the Resource Kit utilities.

    HTH,

    Bill
  • Thursday, July 02, 2009 4:04 PMNickHunyady Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for adding onto my post Bill. It was late when I posted it and didn't get into much detail. I agree, both apps are good for profile cleaning, although Zenfury only mentioned cleaning it from the %Userprofile% path.