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 ...
-
25th August 2005, 03:27 PM #1 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
-
-
IDG Tech News
-
25th August 2005, 06:31 PM #2 Re: Deletion of local profiles on xp.
Can this be run through a GPO or does it have to be run locally?
-
-
25th August 2005, 06:53 PM #3 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 ?
-
-
28th August 2005, 12:28 PM #4 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
-
-
28th August 2005, 03:47 PM #5 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?
-
-
28th August 2005, 04:12 PM #6 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 :-)
-
-
29th August 2005, 11:34 AM #7 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.
-
-
29th August 2005, 12:05 PM #8 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.
-
-
29th August 2005, 07:41 PM #9 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.
-
-
29th August 2005, 08:04 PM #10 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
-
-
29th August 2005, 11:41 PM #11 Re: Deletion of local profiles on xp.
You might want to check out Remote User Profile Cleaner.
http://www.msimons.nl
-
-
30th August 2005, 05:46 PM #12 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 !
-
-
20th October 2006, 08:12 AM #13
- 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
-
-
20th October 2006, 08:21 AM #14 Re: Deletion of local profiles on xp.

Originally Posted by
gecko will have to make a note of that so I dont lose that url
del.icio.us - online social bookmarks.
-
-
20th October 2006, 08:42 AM #15 Re: Deletion of local profiles on xp.

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: 
Similar Threads
-
By Mr_M_Cox in forum Windows
Replies: 43
Last Post: 17th March 2009, 02:02 PM
-
By mattx in forum Windows
Replies: 8
Last Post: 30th October 2007, 02:13 PM
-
Replies: 21
Last Post: 2nd April 2007, 03:02 PM
-
By Behuck in forum Windows
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
-
Forum Rules