?
Solved

Remove all drives accept home folder

Posted on 2008-11-11
2
Medium Priority
?
299 Views
Last Modified: 2012-08-13
Our users home folder is set in the active directory.
I have a logon script that removes all drives and remaps them depending on computer location.

This removes the home folder aswel.
How do I change this code to ignore the U: drive?

' =============================================================================
' Force removal of all network drives
' =============================================================================
On Error Resume Next
DIM objNetwork,colDrives,i
 
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
 
For i = 0 to colDrives.Count-1 Step 2
	objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE
Next

Open in new window

0
Comment
Question by:Antonio King
2 Comments
 
LVL 29

Accepted Solution

by:
Michael Pfister earned 2000 total points
ID: 22929437
Is this what you are looking for? HTH
' =============================================================================
' Force removal of all network drives
' =============================================================================
On Error Resume Next
DIM objNetwork,colDrives,i
 
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
 
For i = 0 to colDrives.Count-1 Step 2
    If colDrives.Item(i) <> "U:" Then
        objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE
    End If
Next

Open in new window

0
 

Author Closing Comment

by:Antonio King
ID: 31515465
Perfect
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question