![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | VBScript that removes and then maps Network Drives - Richard Mueller - are you there? Good morning! This is specifically for Richard Mueller (whose scripts I 'steal' all the time!) regarding one of his logon scripts. Richard, I use "logon3" (http://www.rlmueller.net/Programs/Logon3.txt for those of you not familiar with his site) from your web site and it works very well. I do a lot of things with Security Groups and this specific logon script is awesome. I modify it to fit each environment and away we go. However, there are two questions that I have regarding it that I can not seem to understand: 1) if the client has previously mapped network drives (either manually mapped or via a .bat/.cmd logon script) when I implement your logon script we have a hard time with the "old" mappings going away. About the only way that we can resolve this issue is to manually connect to the machine and disconnect the old mappings. What am I doing wrong? 2) the section on the printers - I was really excited about that part. Then I looked at it. I have a couple of clients who - for a lot of different good reasons - have locked down their printes to specific users. I accomplished this via Security Groups. I was tring to map the printers based on USER group membership. It appears that this script is intended for using security groups of which the COMPUTER is a member. Is there a way to 'modify' this so that the focus is on the USER group membership? Thanks! I really appreciate all of the time that you spend helping the scripting - challenged (like me....but I am working on it). Cary |
My System Specs![]() |
| | #2 (permalink) |
| | Re: VBScript that removes and then maps Network Drives - Richard Mueller - are you there? Tasha wrote: Quote: > Good morning! > > This is specifically for Richard Mueller (whose scripts I 'steal' all the > time!) regarding one of his logon scripts. > > Richard, I use "logon3" (http://www.rlmueller.net/Programs/Logon3.txt for > those of you not familiar with his site) from your web site and it works > very well. I do a lot of things with Security Groups and this specific > logon script is awesome. I modify it to fit each environment and away we > go. > > However, there are two questions that I have regarding it that I can not > seem to understand: > > 1) if the client has previously mapped network drives (either manually > mapped or via a .bat/.cmd logon script) when I implement your logon script > we have a hard time with the "old" mappings going away. About the only > way that we can resolve this issue is to manually connect to the machine > and disconnect the old mappings. What am I doing wrong? persistent connections. The function first attempts to map the specified drive and traps any errors. If there is an error the function then removes any existing mapping. The first "True" parameter on the RemoveNetworkDrive method means to remove the mapping even if it is in use. The second "True" specifies that the removal is persistent (if the mapping was persistent, the registry setting that makes the mapping persistent is removed). Perhaps this later functionality no longer works on the newer clients, since registry permissions are much tighter. I will need to investigate. The function worked fine when I tested on clients up to XP. Note that the script only removes mappings that conflict with the mappings specified in the logon script. If you want to remove all existing mappings (whether or not they conflict with the logon script), you can use the EnumNetworkDrives function of the wshNetwork object. I believe the code would be: ====== Set objNetwork = CreateObject("Wscript.Network") Set objDrives = objNetwork.EnumNetworkDrives For j = 0 To objDrives.Count - 2 Step 2 objNetwork.RemoveNetworkDrive objDrive(j), objDrive(j + 1) Next ====== This won't help you if the RemoveNetworkDrive function is not working for you. Quote: > > 2) the section on the printers - I was really excited about that part. > Then I looked at it. I have a couple of clients who - for a lot of > different good reasons - have locked down their printes to specific users. > I accomplished this via Security Groups. I was tring to map the printers > based on USER group membership. It appears that this script is intended > for using security groups of which the COMPUTER is a member. Is there a > way to 'modify' this so that the focus is on the USER group membership? > > Thanks! I really appreciate all of the time that you spend helping the > scripting - challenged (like me....but I am working on it). > > Cary > membership can be easily modified for user group membership. Simply pass the object reference objUser instead of objComputer to the IsMember function in logon3.vbs. In fact, there is no longer any need to bind to the objComputer object. The code that retrieves the DN of the computer object (and assigns to strComputerDN) can be removed, and the code that binds objComputer can be removed. Simply remove all lines referring to strComputerDN or objComputer (after replacing objComputer with objUser in all calls to IsMember). I hope this helps. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: VBScript that removes and then maps Network Drives - Richard Mueller - are you there? Sorry, I used RemoveNetworkDrive incorrectly in my snippet to remove all drive mappings. It should be: Set objNetwork = CreateObject("Wscript.Network") Set objDrives = objNetwork.EnumNetworkDrives For j = 0 To objDrives.Count - 2 Step 2 objNetwork.RemoveNetworkDrive objDrive(j), True, True Next In fact, here is a similar example from the Microsoft site: http://www.microsoft.com/technet/scr...5/hey0915.mspx -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:OJuKOLYfJHA.5840@xxxxxx Quote: > Tasha wrote: > Quote: >> Good morning! >> >> This is specifically for Richard Mueller (whose scripts I 'steal' all the >> time!) regarding one of his logon scripts. >> >> Richard, I use "logon3" (http://www.rlmueller.net/Programs/Logon3.txt for >> those of you not familiar with his site) from your web site and it works >> very well. I do a lot of things with Security Groups and this specific >> logon script is awesome. I modify it to fit each environment and away we >> go. >> >> However, there are two questions that I have regarding it that I can not >> seem to understand: >> >> 1) if the client has previously mapped network drives (either manually >> mapped or via a .bat/.cmd logon script) when I implement your logon >> script we have a hard time with the "old" mappings going away. About the >> only way that we can resolve this issue is to manually connect to the >> machine and disconnect the old mappings. What am I doing wrong? > Logon3.vbs has a MapDrive function to handle conflicts if the user has > persistent connections. The function first attempts to map the specified > drive and traps any errors. If there is an error the function then removes > any existing mapping. The first "True" parameter on the RemoveNetworkDrive > method means to remove the mapping even if it is in use. The second "True" > specifies that the removal is persistent (if the mapping was persistent, > the registry setting that makes the mapping persistent is removed). > Perhaps this later functionality no longer works on the newer clients, > since registry permissions are much tighter. I will need to investigate. > The function worked fine when I tested on clients up to XP. > > Note that the script only removes mappings that conflict with the mappings > specified in the logon script. If you want to remove all existing mappings > (whether or not they conflict with the logon script), you can use the > EnumNetworkDrives function of the wshNetwork object. I believe the code > would be: > ====== > Set objNetwork = CreateObject("Wscript.Network") > Set objDrives = objNetwork.EnumNetworkDrives > For j = 0 To objDrives.Count - 2 Step 2 > objNetwork.RemoveNetworkDrive objDrive(j), objDrive(j + 1) > Next > ====== > This won't help you if the RemoveNetworkDrive function is not working for > you. > Quote: >> >> 2) the section on the printers - I was really excited about that part. >> Then I looked at it. I have a couple of clients who - for a lot of >> different good reasons - have locked down their printes to specific >> users. I accomplished this via Security Groups. I was tring to map the >> printers based on USER group membership. It appears that this script is >> intended for using security groups of which the COMPUTER is a member. Is >> there a way to 'modify' this so that the focus is on the USER group >> membership? >> >> Thanks! I really appreciate all of the time that you spend helping the >> scripting - challenged (like me....but I am working on it). >> >> Cary >> > The part of the script that maps printers according to computer group > membership can be easily modified for user group membership. Simply pass > the object reference objUser instead of objComputer to the IsMember > function in logon3.vbs. In fact, there is no longer any need to bind to > the objComputer object. The code that retrieves the DN of the computer > object (and assigns to strComputerDN) can be removed, and the code that > binds objComputer can be removed. Simply remove all lines referring to > strComputerDN or objComputer (after replacing objComputer with objUser in > all calls to IsMember). I hope this helps. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: VBScript that removes and then maps Network Drives - Richard Mueller - are you there? Research shows that some people have reported they need to insert a pause (Wscript.Sleep 1000) between the .RemoveNetworkDrive and .MapNetworkDrive function calls. If I get a chance I may try to test on a fast client. The MapDrive function could be modified as follows: If (objDrive.DriveType = 3) Then objNetwork.RemoveNetworkDrive strDrive, True, True Wscript.Sleep 1000 Else This inserts a 1 second pause between the RemoveNetworkDrive and MapNetworkDrive calls. Reply if this helps. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:eOQFlPYfJHA.4868@xxxxxx Quote: > Sorry, I used RemoveNetworkDrive incorrectly in my snippet to remove all > drive mappings. It should be: > > Set objNetwork = CreateObject("Wscript.Network") > Set objDrives = objNetwork.EnumNetworkDrives > For j = 0 To objDrives.Count - 2 Step 2 > objNetwork.RemoveNetworkDrive objDrive(j), True, True > Next > > In fact, here is a similar example from the Microsoft site: > > http://www.microsoft.com/technet/scr...5/hey0915.mspx > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in > message news:OJuKOLYfJHA.5840@xxxxxx Quote: >> Tasha wrote: >> Quote: >>> Good morning! >>> >>> This is specifically for Richard Mueller (whose scripts I 'steal' all >>> the time!) regarding one of his logon scripts. >>> >>> Richard, I use "logon3" (http://www.rlmueller.net/Programs/Logon3.txt >>> for those of you not familiar with his site) from your web site and it >>> works very well. I do a lot of things with Security Groups and this >>> specific logon script is awesome. I modify it to fit each environment >>> and away we go. >>> >>> However, there are two questions that I have regarding it that I can not >>> seem to understand: >>> >>> 1) if the client has previously mapped network drives (either manually >>> mapped or via a .bat/.cmd logon script) when I implement your logon >>> script we have a hard time with the "old" mappings going away. About >>> the only way that we can resolve this issue is to manually connect to >>> the machine and disconnect the old mappings. What am I doing wrong? >> Logon3.vbs has a MapDrive function to handle conflicts if the user has >> persistent connections. The function first attempts to map the specified >> drive and traps any errors. If there is an error the function then >> removes any existing mapping. The first "True" parameter on the >> RemoveNetworkDrive method means to remove the mapping even if it is in >> use. The second "True" specifies that the removal is persistent (if the >> mapping was persistent, the registry setting that makes the mapping >> persistent is removed). Perhaps this later functionality no longer works >> on the newer clients, since registry permissions are much tighter. I will >> need to investigate. The function worked fine when I tested on clients up >> to XP. >> >> Note that the script only removes mappings that conflict with the >> mappings specified in the logon script. If you want to remove all >> existing mappings (whether or not they conflict with the logon script), >> you can use the EnumNetworkDrives function of the wshNetwork object. I >> believe the code would be: >> ====== >> Set objNetwork = CreateObject("Wscript.Network") >> Set objDrives = objNetwork.EnumNetworkDrives >> For j = 0 To objDrives.Count - 2 Step 2 >> objNetwork.RemoveNetworkDrive objDrive(j), objDrive(j + 1) >> Next >> ====== >> This won't help you if the RemoveNetworkDrive function is not working for >> you. >> Quote: >>> >>> 2) the section on the printers - I was really excited about that part. >>> Then I looked at it. I have a couple of clients who - for a lot of >>> different good reasons - have locked down their printes to specific >>> users. I accomplished this via Security Groups. I was tring to map the >>> printers based on USER group membership. It appears that this script is >>> intended for using security groups of which the COMPUTER is a member. >>> Is there a way to 'modify' this so that the focus is on the USER group >>> membership? >>> >>> Thanks! I really appreciate all of the time that you spend helping the >>> scripting - challenged (like me....but I am working on it). >>> >>> Cary >>> >> The part of the script that maps printers according to computer group >> membership can be easily modified for user group membership. Simply pass >> the object reference objUser instead of objComputer to the IsMember >> function in logon3.vbs. In fact, there is no longer any need to bind to >> the objComputer object. The code that retrieves the DN of the computer >> object (and assigns to strComputerDN) can be removed, and the code that >> binds objComputer can be removed. Simply remove all lines referring to >> strComputerDN or objComputer (after replacing objComputer with objUser in >> all calls to IsMember). I hope this helps. >> >> -- >> Richard Mueller >> MVP Directory Services >> Hilltop Lab - http://www.rlmueller.net >> -- >> >> > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: VBScript that removes and then maps Network Drives - Richard Mueller - are you there? Richard, Regarding the printers.....I did make that change and no love. Only if I removed the Group Membership part would it work. Odd.... Environments are WIN2003 Server/WIN2003 R2 Server/SBS2003 Server/WINXP SP2/SP3... I will continue to try this.... I will also look at the part regarding the mapping of network drives. Thanks (as always). Cary "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:OJuKOLYfJHA.5840@xxxxxx Quote: > Tasha wrote: > Quote: >> Good morning! >> >> This is specifically for Richard Mueller (whose scripts I 'steal' all the >> time!) regarding one of his logon scripts. >> >> Richard, I use "logon3" (http://www.rlmueller.net/Programs/Logon3.txt for >> those of you not familiar with his site) from your web site and it works >> very well. I do a lot of things with Security Groups and this specific >> logon script is awesome. I modify it to fit each environment and away we >> go. >> >> However, there are two questions that I have regarding it that I can not >> seem to understand: >> >> 1) if the client has previously mapped network drives (either manually >> mapped or via a .bat/.cmd logon script) when I implement your logon >> script we have a hard time with the "old" mappings going away. About the >> only way that we can resolve this issue is to manually connect to the >> machine and disconnect the old mappings. What am I doing wrong? > Logon3.vbs has a MapDrive function to handle conflicts if the user has > persistent connections. The function first attempts to map the specified > drive and traps any errors. If there is an error the function then removes > any existing mapping. The first "True" parameter on the RemoveNetworkDrive > method means to remove the mapping even if it is in use. The second "True" > specifies that the removal is persistent (if the mapping was persistent, > the registry setting that makes the mapping persistent is removed). > Perhaps this later functionality no longer works on the newer clients, > since registry permissions are much tighter. I will need to investigate. > The function worked fine when I tested on clients up to XP. > > Note that the script only removes mappings that conflict with the mappings > specified in the logon script. If you want to remove all existing mappings > (whether or not they conflict with the logon script), you can use the > EnumNetworkDrives function of the wshNetwork object. I believe the code > would be: > ====== > Set objNetwork = CreateObject("Wscript.Network") > Set objDrives = objNetwork.EnumNetworkDrives > For j = 0 To objDrives.Count - 2 Step 2 > objNetwork.RemoveNetworkDrive objDrive(j), objDrive(j + 1) > Next > ====== > This won't help you if the RemoveNetworkDrive function is not working for > you. > Quote: >> >> 2) the section on the printers - I was really excited about that part. >> Then I looked at it. I have a couple of clients who - for a lot of >> different good reasons - have locked down their printes to specific >> users. I accomplished this via Security Groups. I was tring to map the >> printers based on USER group membership. It appears that this script is >> intended for using security groups of which the COMPUTER is a member. Is >> there a way to 'modify' this so that the focus is on the USER group >> membership? >> >> Thanks! I really appreciate all of the time that you spend helping the >> scripting - challenged (like me....but I am working on it). >> >> Cary >> > The part of the script that maps printers according to computer group > membership can be easily modified for user group membership. Simply pass > the object reference objUser instead of objComputer to the IsMember > function in logon3.vbs. In fact, there is no longer any need to bind to > the objComputer object. The code that retrieves the DN of the computer > object (and assigns to strComputerDN) can be removed, and the code that > binds objComputer can be removed. Simply remove all lines referring to > strComputerDN or objComputer (after replacing objComputer with objUser in > all calls to IsMember). I hope this helps. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| logon vbscript mapping drives | VB Script | |||
| VBscript to clear My Network Places? | VB Script | |||
| Missing drives (harddrive, cdrom and maaped network drives) | Vista General | |||
| Norton Internet Security (NIS) removes ability to turn off Network Discovery/File Sharing | Vista security | |||
| safely remove removes all drives | Vista hardware & devices | |||