There isn't really any simple solution to this. You could map both drives in a single logon script, but then configure permissions so users can access either one or the other (depending who they logon as).
This is easy in a domain, but my scenario is a workgroup of XP Pro PCs. One is designated as a File Server and I need to be able to map to a particular folder, depending upon the group to which the user belongs. I have a startup script in the C:\...\All Users\Start Menu\Programs\Startup of each PC and would like to add to it. I know I can have:
orCode:net use * /delete net use f: \\server\AdminShare
etc. in each specific users' Startup folder but I'd like to have it run from the All Users' Startup folder so I don't have to put the login script into the specific folder when I create new users and allocate them to groups.Code:net use * /delete net use g: \\server\OtherShare
Is there any way to do this? I thought of this pseudocode:
Maybe someone can suggest a simpler solution for me? I know that the syntax that I've given isn't VBS but I'd hope to incorporate any suggestions into my VBS login script.Code:net use * /delete if group = "Administrators" then net use f: \\server\AdminShare goto end if group = "Power Users" then net use f: \\server\OtherShare goto end
Thanks in advance.
There isn't really any simple solution to this. You could map both drives in a single logon script, but then configure permissions so users can access either one or the other (depending who they logon as).
Thanks Michael. I've configured the share and folder permissions appropriately. I'd prefer to hide folders to which users don't have access, hence the idea of deleting all the mapped folders and recreating the mapping at each login.
Since posting earlier today, I've investigated further:
will get me a list of local groups. I can run through them:Code:net localgroup > group.txt
but I'll need to save the groupname to a variable if "Name" is found in this group.Code:net localgroup <groupname> | find "Name" (I need to check the syntax of passing %username% to this line)
I *think* I'm on the right track but realise that it's not so easy as it would be if it were a domain.
This article may point you in the right direction.
Ignatius (20-06-2009)
Thanks again. I'd had a look at that site and suspect that the code relates to a domain rather than a workgroup. When it mentions "groups", I think it refers to AD groups.
I'll be able to test this out early next week on the workgroup and I'll also have access to a Windows 2003 and single XP Pro client to check out whether it's only for a domain.
You should be able to use the code below. Basically, it gets the name of the user and computer, clears all existing drive mappings and then connects to the user object to get its properties. It then loops through all the groups, converts the name to lower case (may not be necessary but does no harm ...) and then calls a routine to check what drives should be mapped for the groups.
You'll need to change the "mapdrive" subroutine to deal with the groups you have and the shares you want to use.
the only thing this won't cope with is nested groups but I'm guessing that in a workgroup you're not likely to have such a problem.
Code:Set oNetwork = CreateObject("Wscript.Network") sUser=oNetwork.UserName sComputer=oNetwork.computername ClearMappedDrives set oUser=getobject("WinNT://" & sComputer & "/" & sUser) for each oGroup in oUser.groups sGroup=lcase(oGroup.name) MapDrive sGroup next sub clearmappeddrives set oDrives=oNetwork.enumnetworkdrives For i = 0 to oDrives.Count - 1 Step 2 onetwork.removenetworkdrive oDrives.Item(i) Next end sub sub MapDrive(sGroup) select case sGroup case "administrators" oNetwork.mapnetworkdrive "z:","\\computer1\share1" oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs" case "finance" oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs" case "registry" oNetwork.mapnetworkdrive "q:","\\computer2\sharedocs" end select end sub
Ignatius (21-06-2009)
Thanks Steve - that looks good. I'll be able to test it within the next few days.
There are currently 1 users browsing this thread. (0 members and 1 guests)