hidden hit counter
Help!

login script to remove mapped drives

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Group Policy RSS
Next:  same scheduled task get fired multiple times?  
Author Message
Bunert
External


Since: Oct 05, 2006
Posts: 12



PostPosted: Wed Oct 25, 2006 1:57 pm    Post subject: login script to remove mapped drives
Archived from groups: microsoft>public>win2000>group_policy (more info?)

I have a login script that maps some drives and copies some files. It works
great.

I have some users that have mapped some drives to locations on the network
that no longer exist. I want to delete the mappings as the login script
remaps them properly. The delete does not work from within the login script
but it works if manually typed on the client at the cmd prompt.

I am using:

NET USE X: /DELETE /YES to delete the persistent mapping. (I also tried
without the /YES)

If in my login script, the X: drive does not delete - although in the same
login script I map a U: drive which maps ok so I know the script is being
called and functional.

If I go to the client and do type the the /delete at the cmd prompt - the X:
drive gets deleted properly.

If I put the login script on the client desktop and run it there, the X
drive does not delete. I do not get a "command completed successfully" -
however I do not get an error either.

Any thoughts?

thanks
Back to top
user5758
External


Since: Jan 30, 2005
Posts: 294



PostPosted: Thu Oct 26, 2006 12:37 pm    Post subject: Re: login script to remove mapped drives [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi,

Bunert schrieb:
> I am using:
> NET USE X: /DELETE /YES to delete the persistent mapping. (I also tried
> without the /YES)

Did you try "net use *" (Asterix) instead of the driveletter?

Mark
--
Mark Heitbrink - MVP Windows Server - Group Policy

Homepage: www.gruppenrichtlinien.de - deutsch
Blog: gpupdate.spaces.live.com - english
Back to top
KTosser
External


Since: Feb 16, 2006
Posts: 2



PostPosted: Thu Oct 26, 2006 12:37 pm    Post subject: Re: login script to remove mapped drives [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You could try using a vbs login script. I have used these before with
great success.

This first one will remove mappings and then set mappings for all users
that get the script:

<<Script Start>>
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

'removes mapped drive H
objNetwork.RemoveNetworkDrive "H:", True, True

'creats maped drive H
objNetwork.MapNetworkDrive "H:", "\\Server\Share"
<<Script End>

Or this second one will map differently depending on what AD security
groups they are members of

<<Start Script>>
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

strUserPath = "LDAP://" & objSysInfo.ComputerName
Set objUser = GetObject(strUserPath)

'Finds users group membership
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN

'Removes curent mappings
objNetwork.RemoveNetworkDrive "H:", True, True
objNetwork.RemoveNetworkDrive "I:", True, True
objNetwork.RemoveNetworkDrive "R:", True, True
objNetwork.RemoveNetworkDrive "S:", True, True
objNetwork.RemoveNetworkDrive "T:", True, True


'Mappings for all users
objNetwork.MapNetworkDrive "H:", "\\Server\Share"


'Mappings Based on Group Membership
Select Case strGroupName

Case "Group 1"
objNetwork.MapNetworkDrive "I:", "\\Server\Share1"

Case "Group 2"
objNetwork.MapNetworkDrive "R:", "\\Server\Share 2"

Case "Group 3"
objNetwork.MapNetworkDrive "S:", "\\Server\Share 3"

Case "Group 4"
objNetwork.MapNetworkDrive "T:", "\\Server\Share 4"

End Select
Next
<<End Script>>

Hope one of these will help.
Back to top
Wiley



Joined: Oct 30, 2006
Posts: 6



PostPosted: Mon Dec 11, 2006 3:21 am    Post subject: [Login to view extended thread Info.]

You can try: net use * /del, but there is another way. For example, I use Desktop Authority for drive mappings. I have an opportunity to delete current drive mappings while configuring new ones by using a single checkbox.
Back to top
SimplySupport



Joined: Apr 26, 2008
Posts: 1



PostPosted: Sat Apr 26, 2008 4:57 pm    Post subject: This works! [Login to view extended thread Info.]

I think everyone was having some minor context issues that were preventing this from working. The following is case sensitive, and works.

NET USE * /DELETE /Y

This will clear all mapped drives, without prompting, and allow you to create new ones without conflict.

You can substitute the "*" for "?:", the question mark being what ever letter you want disconnected. This worked without a problem on the administrator account of SBS2003 test box. I have not confirmed it with users on the domain, as I don't have any systems attached to this server at this time. Hope this helps!
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Group Policy All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum