+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
Scripts Thread, Deletion of local profiles on xp. in Coding and Web Development; ok I have this vbscript below which is to delete all local profiles except for the specific ones which are ...
  1. #1

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,215
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343

    Deletion of local profiles on xp.

    ok I have this vbscript below which is to delete all local profiles except for the specific ones which are in the select case statement :

    Code:
    Function Main()
    On Error Resume Next
    Dim obtainfolder
    Dim PathFolder
    Dim strPath
    
    
    	Set fso = CreateObject("Scripting.FileSystemObject")
    
    	strPath = "C:\Documents and Settings\"
    
    	Set f = fso.GetFolder(strPath)
    
    	' Loop through all subfolders
    	For Each fldrItem in f.SubFolders
    
    	fldrName = fldrItem.name
    
    	If Right(strPath,1) <> "\" Then
    	PathFolder = strPath & "\" & fldrName
    	Else
    	PathFolder = strPath & fldrName
    	End If
    
    	Select Case fldrName
    	Case "Administrator":
     	Case "All Users":
    	Case "Default User":
    	Case "supervisor.CSE2K"
    	Case "supervisor":
    	Case "sweepupd"
    	Case "sweepupd.CSE2K"
    	Case "LocalService":
    	Case "NetworkService":
    	Case Else:
    
    	set obtainfolder = fso.GetFolder(PathFolder)    
    	obtainfolder.Delete true       
    	End Select
    
    	Next
    
    	' Clean up objects
    	Set fso = Nothing
    	Set fc = Nothing
    
    End Function
    
    call Main()
    now I would like help with it so that It can have an array which is re dimmed each time it gets to a folder which can not be deleted and take that folders name and stores that folders name into the array so that near the end of this vbscript it has some way of detecting once the script has finished doing what it can and then prompts you with all the folders ( local profiles ) that it could not delete and also get the size of the documents and settings folder before and after and in the messagebox show the amount in mb of how much it has cleared out or freed.

    I hope that makes sense

    If anyone can make any suggestions to improve this script aside from that, then feel free to make them.

    Thanks

    Shane

  2. #2
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    21

    Re: Deletion of local profiles on xp.

    Can this be run through a GPO or does it have to be run locally?

  3. #3

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,215
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343

    Re: Deletion of local profiles on xp.

    Just so you know I am working under the network manager and am learning about server 2003.

    ok GPO as in group policies correct ?

    If so then it depends on how GPO would make this work, so far we have just run it locally.

    If I figured out how to use UNC paths and such like in vbs then I am sure you could run it from the server , but if you were going to do something like that then it would be worth while just making an application in visual basic or another language that would do it then.

    I think a better way would be a login script possibly or even a log out script maybe ?

    Maybe you can ellaborate on how GPO would run the script or how it would work with GPO etc ?

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,215
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343

    Re: Deletion of local profiles on xp.

    I have an updated one if anyone is interested in any updated versions of this script then please post back here

    I will be working on the UNC version later on

    If you would like a script like this that would work with GPO then please let me know here

    Thanks

  5. #5

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,582
    Thank Post
    107
    Thanked 761 Times in 592 Posts
    Rep Power
    179

    Re: Deletion of local profiles on xp.

    You could add this to the startup script in the GPO (Group Policy Object) for your machines.

    Would the Microsoft tool (Delprof) not suffice for what you want?

  6. #6

    Join Date
    Jul 2005
    Location
    Corby
    Posts
    1,056
    Thank Post
    12
    Thanked 20 Times in 18 Posts
    Rep Power
    23

    Re: Deletion of local profiles on xp.

    Good point actually. I think we started using the script that Gecko wrote so that we didn't delete profiles that we aren't (because of our managed solution on those machines) supposed to delete (or can't). But thinking about it, isn't there a command-line switch you can use with DelProf that let's you decide whether a profile is deleted or not---is it DELPROF /P?

    ...got me thinking though, and that's very dangerous at the weekend!

    Paul :-)

  7. #7
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    21

    Re: Deletion of local profiles on xp.

    I thought there was a setting in server 2003 GPO that you can set that deletes or does not store profiles?

    Can't remember the official wording, will lookwhe i am back in on Wednesday.

  8. #8
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,414
    Thank Post
    193
    Thanked 247 Times in 120 Posts
    Rep Power
    61

    Re: Deletion of local profiles on xp.

    Tosca925 is correct there is a GPO setting that allows for either profiles to be deleted at logoff or not to be stored at all.

    For the life of me I can not remember where it is but i'll also take a look on Wednesday.

  9. #9

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,582
    Thank Post
    107
    Thanked 761 Times in 592 Posts
    Rep Power
    179

    Re: Deletion of local profiles on xp.

    It's something like delete cached profiles on logoff but it doesn't always work - hence why MS developed the Delprof utility.

    Check out the document at http://www.microsoft.com/downloads/d...DisplayLang=en which tells you all the GPO settings that are available and where they live.

  10. #10
    tosca925's Avatar
    Join Date
    Aug 2005
    Location
    Midlands
    Posts
    1,547
    Thank Post
    4
    Thanked 4 Times in 4 Posts
    Rep Power
    21

    Re: Deletion of local profiles on xp.

    It's something like delete cached profiles on logoff but it doesn't always work
    Yeah i've noticed that it does not always work, thought i was going mad to start with.

    Thanks for the GPO link, will have a look at that when i have got 5

  11. #11

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,800
    Thank Post
    110
    Thanked 582 Times in 503 Posts
    Blog Entries
    1
    Rep Power
    223

    Re: Deletion of local profiles on xp.

    You might want to check out Remote User Profile Cleaner.

    http://www.msimons.nl

  12. #12

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,215
    Thank Post
    2,766
    Thanked 935 Times in 875 Posts
    Rep Power
    343

    Re: Deletion of local profiles on xp.

    thats a cool website will have to make a note of that so I dont lose that url, thanks Geoff !

  13. #13

    Join Date
    Jul 2006
    Location
    uk
    Posts
    6
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Deletion of local profiles on xp.

    Hi. Does anyone know how to creat a batch file to remotly delete profiles using delprof except Administrator,defual and some specific profile. I can see someone done a VB but I require a batch file realy. any help apreciated..please dont reply and say use "Remot profile cleaner". thanks

  14. #14

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,374
    Thank Post
    625
    Thanked 951 Times in 653 Posts
    Blog Entries
    2
    Rep Power
    318

    Re: Deletion of local profiles on xp.

    Quote Originally Posted by gecko
    will have to make a note of that so I dont lose that url
    del.icio.us - online social bookmarks.

  15. #15

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    777
    Thank Post
    1
    Thanked 31 Times in 29 Posts
    Rep Power
    23

    Re: Deletion of local profiles on xp.

    Quote Originally Posted by marx
    Hi. Does anyone know how to creat a batch file to remotly delete profiles using delprof except Administrator,defual and some specific profile. I can see someone done a VB but I require a batch file realy. any help apreciated..please dont reply and say use "Remot profile cleaner". thanks
    Delprof will delete all user profiles but you could copy the profiles you want keep somewhere and bring them back in after you run delprof

    Something like this:

    XCOPY /S "C:\Documents and Settings\%userprofile%" "C:\ProfileBackupFolder\%userprofile%"

    DELPROF /Q /I

    XCOPY /S "C:\ProfileBackupFolder\%userprofile%" "C:\Documents and Settings\%userprofile%"

    Delprof will not touch any other folders in the "C:\Documents and Settings" folders, such as "All Users", "Default User, "LocalService" and
    "NetworkService", it will only delete "real" user profiles.

    I would run the batch file in a computer shutdown script (with a GPO) that runs as part of the or shutdown process becuase it could take a long time to delete the profiles.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Deleting Local Profiles
    By Mr_M_Cox in forum Windows
    Replies: 43
    Last Post: 17th March 2009, 02:02 PM
  2. Replies: 8
    Last Post: 30th October 2007, 02:13 PM
  3. Local admins and Mandatory Profiles
    By Bobo in forum Windows
    Replies: 21
    Last Post: 2nd April 2007, 03:02 PM
  4. Replies: 17
    Last Post: 14th December 2006, 01:52 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •