Re: VBScript that removes and then maps Network Drives - Richard Mueller - are you there?

Tech-Archive recommends: Speed Up your PC by fixing your registry



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@xxxxxxxxxxxxxxxxxxxx> wrote in message news:OJuKOLYfJHA.5840@xxxxxxxxxxxxxxxxxxxxxxx
Tasha wrote:

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.


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
--



.



Relevant Pages

  • Re: Setting printer acl using computer account instead of user account
    ... We have requirement of mapping the network printers based on computer ... A logon script can retrieve the NetBIOS name of the local computer and map ... user group membership and printers according to computer group membership: ...
    (microsoft.public.windows.server.general)
  • Re: Mapping Network Drives and Trapping Errors to Return Success or Failure.
    ... >> In a logon script, it is not going to be of much value to explain the ... >> of the failure to the user. ... > user for all of the reasons you state. ... hosting the share is down, for example, then it will affect everyone mapping ...
    (microsoft.public.scripting.vbscript)
  • Re: Mapping Network Drives and Trapping Errors to Return Success or Failure.
    ... > In a logon script, it is not going to be of much value to explain the cause ... user for all of the reasons you state. ... So while mapping a path that exists works fine, ... Dim objNetwork: Set objNetwork = Script.CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: logon script
    ... > I already have a batch file as the logon script, ... Now I like to add a line that map network printer. ... Looks like mapping ... but not for net work printer. ...
    (microsoft.public.windows.server.scripting)
  • Re: Logon Script
    ... I have recently taken over an environment where all mapped drives were ... Has any created a single logon script where I can list ... Security Group membership of a particular user? ...
    (microsoft.public.windows.server.scripting)