+ Post New Thread
Results 1 to 13 of 13
Scripts Thread, VBS to remove Profiles on logon (Works!) in Coding and Web Development; Here is the script i use to remove profiles when a user logs on as we use roaming profiles for ...
  1. #1

    Join Date
    Jun 2008
    Posts
    8
    Thank Post
    1
    Thanked 4 Times in 1 Post
    Rep Power
    0

    Smile VBS to remove Profiles on logon (Works!)

    Here is the script i use to remove profiles when a user logs on as we use roaming profiles for students but the local folder is still created. This removes it before anyon logs on.


    '*******Remove Profiles********
    Const LocalDocumentsFolder = "C:\Documents and Settings\"

    set objFSO = createobject("Scripting.FileSystemObject")
    set objFolder = objFSO.GetFolder(localdocumentsfolder)

    on error resume next

    for each fldr in objFolder.SubFolders
    if not isexception(fldr.name) then
    objFSO.DeleteFolder fldr.path, True
    end if
    next

    '*******Folder you want to keep*******
    Function isException(byval foldername)
    select case foldername
    case "All Users"
    isException = True
    case "Default User"
    isException = True
    case "LocalService"
    isException = True
    case "NetworkService"
    isException = True
    case "Administrator"
    isException = True
    case Else
    isException = False
    End Select
    End Function

  2. 4 Thanks to andrew_obrien:

    garethedmondson (5th March 2009), Jamman960 (13th April 2009), Marci (22nd April 2009), rh91uk (5th March 2009)

  3. #2
    rh91uk's Avatar
    Join Date
    Sep 2008
    Location
    UK
    Posts
    877
    Thank Post
    137
    Thanked 132 Times in 114 Posts
    Rep Power
    36
    Thanks for this Andrew - this has been very helpful in solving a problem.

  4. #3

    Join Date
    Nov 2008
    Location
    slough
    Posts
    35
    Thank Post
    5
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    can you run this on log off?

  5. #4
    leco's Avatar
    Join Date
    Nov 2006
    Location
    West Yorkshire
    Posts
    2,026
    Thank Post
    595
    Thanked 125 Times in 119 Posts
    Rep Power
    41
    This script looks interesting and maybe just what I'm looking for. Could someone please tell me how I make and run it, please? Where do I store it - Netlogon/scripts perhaps or somewhere else? I have a Win2008 64 bit server, functional level Win2003.

  6. #5

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,225
    Thank Post
    874
    Thanked 2,717 Times in 2,302 Posts
    Blog Entries
    11
    Rep Power
    780
    This should provide some answers:
    Create System Startup / Shutdown and User Logon / Logoff Scripts

    just need to save it as a .vbs file in notepad, put in a network location as linked and add it to a gpo to apply it.
    Last edited by SYNACK; 13th April 2009 at 02:24 PM.

  7. Thanks to SYNACK from:

    leco (13th April 2009)

  8. #6
    leco's Avatar
    Join Date
    Nov 2006
    Location
    West Yorkshire
    Posts
    2,026
    Thank Post
    595
    Thanked 125 Times in 119 Posts
    Rep Power
    41
    Good job I'm on holiday, more time to read and digest. Thanks for this will do my homework and have a bash. This learning curve thingy is getting less steep

  9. #7
    leco's Avatar
    Join Date
    Nov 2006
    Location
    West Yorkshire
    Posts
    2,026
    Thank Post
    595
    Thanked 125 Times in 119 Posts
    Rep Power
    41
    Some more questions on this which may or not be relevant. If this is a Logon/Logoff script can I still put it in an OU for machines? e.g. I have all the classroom computers in one unit in AD, can I apply the script to those machines even though this is a User script? Does that make sense or am I talking gibberish (through ignorance of the issue)?

  10. #8
    ChrisP's Avatar
    Join Date
    Apr 2007
    Location
    norfolk
    Posts
    150
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    17
    hi, just a couple of observations..

    1. delprof.exe is a very useful for sticking in batches ( got some handy switches /c: (remote computer) /d: (days inactive) etc.)
    2. remember NEVER to run it on a laptop. lol
    3. you can compound your case statements...

    Code:
    select case foldername
    
    case "All Users", "Default User", "LocalService", "NetworkService", "Administrator"
     isException = True
    case Else
     isException = False
    End Select
    4. to make it a bit more robust for a production environment it may be a good idea to rename the folder first, then delete. WHY?
    Ever tried to delete a profile and ntuser.dat was locked? then you had to restart to delete it?

    with the script as it is (and delprof for that matter) it would result in a half deleted (corrupt) profile. if you had a rename element in the script the rename function would fail and not proceed to delete the profile. Ergo the profile still works and when the PC is next rebooted the script should work as expected
    Last edited by ChrisP; 15th April 2009 at 01:47 PM.

  11. Thanks to ChrisP from:

    Marci (22nd April 2009)

  12. #9
    leco's Avatar
    Join Date
    Nov 2006
    Location
    West Yorkshire
    Posts
    2,026
    Thank Post
    595
    Thanked 125 Times in 119 Posts
    Rep Power
    41
    Please excuse my ignorance - why NEVER on a laptop?

    Thanks for the info though.

  13. #10

    Join Date
    May 2007
    Location
    Suffolk
    Posts
    145
    Thank Post
    2
    Thanked 19 Times in 17 Posts
    Rep Power
    18
    I would imagine its because you would need a profile present, when not connected to the doamin, to successfully log in.

    Just a guess from the dark!

  14. #11

    Join Date
    Feb 2008
    Posts
    270
    Thank Post
    14
    Thanked 44 Times in 35 Posts
    Rep Power
    22
    Im presuming because if they use a local login account for use away from the network it will delete all of their saved documents / pictures / music etc ?

  15. Thanks to ssiruuk2 from:

    leco (15th April 2009)

  16. #12
    leco's Avatar
    Join Date
    Nov 2006
    Location
    West Yorkshire
    Posts
    2,026
    Thank Post
    595
    Thanked 125 Times in 119 Posts
    Rep Power
    41
    thanks ssiruuk2, that kinda makes sense. Our laptop users have roaming profiles with offline folders, so might it have the same effect if a local cache had been created by the profile?

  17. #13
    ChrisP's Avatar
    Join Date
    Apr 2007
    Location
    norfolk
    Posts
    150
    Thank Post
    4
    Thanked 8 Times in 8 Posts
    Rep Power
    17
    thats correct

    When one of my technicians started he delproffed a laptop and blitzed a profile with 2 gigs worth of photos and documents.

    his next lesson was on file recovery.

SHARE:
+ Post New Thread

Similar Threads

  1. vbs logon with ie
    By box_l in forum Scripts
    Replies: 5
    Last Post: 11th August 2010, 11:35 PM
  2. Limit Logon VBS Version
    By ChrisH in forum Scripts
    Replies: 29
    Last Post: 17th August 2009, 02:47 PM
  3. VBS Logon Scrip
    By brahma in forum Windows
    Replies: 14
    Last Post: 12th August 2008, 03:58 PM
  4. How do you remove interactive logon
    By speckytecky in forum Windows
    Replies: 7
    Last Post: 29th July 2008, 05:16 PM
  5. Replies: 5
    Last Post: 12th December 2006, 06:06 AM

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
  •