Solved

Using "ifmember" to map network drives for users in multiple groups.

Posted on 2007-04-03
6
1,004 Views
Last Modified: 2008-01-09
Using "ifmember" to map network drives for users in multiple groups.

His guys, I'm trying to use "ifmember" to map network drives for users in multiple group, but it will only map the needed drives for users in the first group that fines. Here is the bat file that I'm using.

::test for membership - goto appropriate group
ifmember "mydomain\mydomain Accounting" || goto mydomainAccounting
ifmember "mydomain\mydomain Payable" || goto mydomainAccountsPayable
ifmember "mydomain\mydomain Accounts Receivable" ||  goto mydomainAccountsReceivable
ifmember "mydomain\mydomain Authorized ETA" || goto mydomaindETA
ifmember "mydomain\mydomain Escheat" || goto mydomainescheat
ifmember "mydomain\mydomain Escrow Trust Accounting" || goto mydomainETA
ifmember "mydomain\mydomain Executive" || goto mydomainexecutive
ifmember "mydomain\mydomain GeneralLedger" || goto mydomainGeneralLedger
ifmember "mydomain\mydomain HR Related" || goto mydomainHumanResources
::if not a member of any of the above - goto global mapping
goto global

:mydomainAccounting
net use g: \\mydomain\accounting /persistent:no
net use j: \\mydomain\journal /persistent:no
net use m: \\mydomain\ap /persistent:no
net use r: \\mydomain\ar /persistent:no
net use l: \\mydomain\gl /persistent:no
goto global

:mydomainAccountsPayable
net use n: \\mydomain\ap /persistent:no
goto global

:mydomainAccountsReceivable
net use g: \\mydomain\accounting /persistent:no
net use r: \\mydomain\ar /persistent:no
net use t: \\mydomain\eta /persistent:no
goto global

:mydomaindETA
net use g: \\mydomain\accounting /persistent:no
net use t: \\mydomain\eta /persistent:no
net use z: \\mydomain\authorizedeta /persistent:no
goto global

:mydomainescheat
net use k: \\mydomain\1099 /persistent:no
net use n: \\mydomain\escheat /persistent:no
net use t: \\mydomain\eta /persistent:no
goto global

:mydomainETA
net use t: \\mydomain\eta
goto global

:mydomainexecutive
net use p: \\mydomain\legal
net use x: \\mydomain\executive
goto global

:mydomainGeneralLedger
net use g: \\mydomain\accounting
net use j: \\mydomain\journal
net use l: \\mydomain\gl
net use m: \\mydomain\ap
net use r: \\mydomain\ar
goto global

:mydomainHumanResources
net use f: \\mydomain\apps
net use g: \\mydomain\accounting
net use i: \\mydomain\installs
net use o: \\mydomain\hr
net use y: \\mydomain\payrollhr
net use u: \\mydomain\everyone
goto global

:global
net use U: \\mydomain\everyone /persistent:no
net use I: \\mydomain\installs /persistent:no

exit

***Credit to Sirbounty for the bat file***
0
Comment
Question by:bleonard55301
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18847574
Hello again! :^)

You'll need to 'call' those subsections if you want to continue testing:
I changed the goto's to call's...execution should return and process the subsequent tests.... I also changed all the section goto globals to goto :eof (since goto global is the 'final' execution...)


::test for membership - goto appropriate group
ifmember "mydomain\mydomain Accounting" || call :mydomainAccounting
ifmember "mydomain\mydomain Payable" || call :mydomainAccountsPayable
ifmember "mydomain\mydomain Accounts Receivable" ||  call :mydomainAccountsReceivable
ifmember "mydomain\mydomain Authorized ETA" || call :mydomaindETA
ifmember "mydomain\mydomain Escheat" || call :mydomainescheat
ifmember "mydomain\mydomain Escrow Trust Accounting" || call :mydomainETA
ifmember "mydomain\mydomain Executive" || call :mydomainexecutive
ifmember "mydomain\mydomain GeneralLedger" || call :mydomainGeneralLedger
ifmember "mydomain\mydomain HR Related" || call :mydomainHumanResources
::if not a member of any of the above - goto global mapping
goto global

:mydomainAccounting
net use g: \\mydomain\accounting /persistent:no
net use j: \\mydomain\journal /persistent:no
net use m: \\mydomain\ap /persistent:no
net use r: \\mydomain\ar /persistent:no
net use l: \\mydomain\gl /persistent:no
goto :eof

:mydomainAccountsPayable
net use n: \\mydomain\ap /persistent:no
goto :eof

:mydomainAccountsReceivable
net use g: \\mydomain\accounting /persistent:no
net use r: \\mydomain\ar /persistent:no
net use t: \\mydomain\eta /persistent:no
goto :eof

:mydomaindETA
net use g: \\mydomain\accounting /persistent:no
net use t: \\mydomain\eta /persistent:no
net use z: \\mydomain\authorizedeta /persistent:no
goto :eof

:mydomainescheat
net use k: \\mydomain\1099 /persistent:no
net use n: \\mydomain\escheat /persistent:no
net use t: \\mydomain\eta /persistent:no
goto :eof

:mydomainETA
net use t: \\mydomain\eta
goto :eof

:mydomainexecutive
net use p: \\mydomain\legal
net use x: \\mydomain\executive
goto :eof

:mydomainGeneralLedger
net use g: \\mydomain\accounting
net use j: \\mydomain\journal
net use l: \\mydomain\gl
net use m: \\mydomain\ap
net use r: \\mydomain\ar
goto :eof

:mydomainHumanResources
net use f: \\mydomain\apps
net use g: \\mydomain\accounting
net use i: \\mydomain\installs
net use o: \\mydomain\hr
net use y: \\mydomain\payrollhr
net use u: \\mydomain\everyone
goto :eof

:global
net use U: \\mydomain\everyone /persistent:no
net use I: \\mydomain\installs /persistent:no

exit
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18847580
Try changing each "goto mydomainAccounting" bits to call :myDomainAccounting then change the "goto global" after each to goto :eof so it drops to the end of the file and out of the subroutine call each time.

That will then call each set of drive mappings as a subroutine.  Note however it won't overwrite a drive mapping unless you put in some net use x: /delete commands so the first "g: "will win as it stands.


0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18847582
:-) Guess I was a bit slow hitting submit there!!
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18847590
There'll be other days Steve... ;^)
0
 

Author Comment

by:bleonard55301
ID: 18848398
Works great!! A+ answer thanks SirBounty!!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18849428
Happy to help - thanx : )
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

705 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