[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3513
  • Last Modified:

detecting group membership for batch file

guys

looking to create a batch file for our 2003 domain.

basically i want to map different drives depending upon a users group membership.  
0
COGNOTEC
Asked:
COGNOTEC
  • 4
  • 3
1 Solution
 
nappy_dCommented:
0
 
COGNOTECAuthor Commented:
not too familiar with that command

What I was thinking was along the lines of this


Here's what I have so far.


@echo off

:Begin
CLS

REM Deletes all existing drive mappings
net use f: /delete
net use g: /delete
net use h: /delete
net use i: /delete
net use J: /delete
net use k: /delete
net use l: /delete
net use m: /delete
net use n: /delete
net use o: /delete
net use p: /delete
net use q: /delete
net use r: /delete
net use s: /delete
net use t: /delete
net use u: /delete
net use v: /delete
net use w: /delete
net use x: /delete
net use y: /delete
net use z: /delete



REM connect to home drive & Reception Printer
net use i: \\fileserver\home\%username%
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\reception


IF Group ==Dev GOTO Dev
IF Group ==Technical_services GOTO Tech_serv
IF Group ==London GOTO London
IF Group ==Ney_york GOTO New_york
IF Group ==Singapore GOTO Sing
IF Group ==VIP_Manager GOTO VIP
IF Group ==PTG GOTO PTG
If GROUP ==Finance GOTO Finance
if GROUP == HR GOTO HR


GOTO END



:Dev
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\dev
net use r: \\fileserver\dub
GOTO END




:Tech_serv
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\tech
net use r: \\fileserver\dub
net use z: \\fileserver\apps
GOTO END



:London
REM rundll32 printui.dll,PrintUIEntry /in /n \\printserver\eng
net use r: \\fileserver\london
GOTO END


:New_york
net use r: \\fileserver\ney_york
GOTO END


:Sing
net use r: \\fileserver\sing
GOTO END


:VIP
net use v: \\fileserver\vip
GOTO END

:PTG
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\ptg
net use p: \\fileserver\ptg
net use r: \\fileserver\dub
GOTO END



:Finance
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\finance
net use f: \\fileserver\finance
GOTO END


:HR
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\hr
net use h: \\fileserver\HR
GOTO END




:END
0
 
nappy_dCommented:
Here is what mine looks like with the ifmember and it is easy to adapt your script to it...

You have to download the ifmember.exe from the link I posted and the ifmember.exe file MUST be located at the root level in which you have this batch script

@echo off
 
:Begin
CLS
 
REM Deletes all existing drive mappings
REM Start of nappy_d's edits
net use * /delete
REM end of nappy_d's edits
 
REM connect to home drive & Reception Printer
net use i: \\fileserver\home\%username%
rundll32 printui.dll,PrintUIEntry /in /n \\printserver\reception
 
REM start of nappy_d's edits
ifmember "Domain\Dev" || GOTO Dev
ifmember "Domain\Technical_services" || GOTO Tech_serv
ifmember "Domain\London" || GOTO London
ifmember "Domain\Ney_york" || GOTO New_york
ifmember "Domain\Singapore" || GOTO Sing
ifmember "Domain\VIP_Manager" || GOTO VIP
ifmember "Domain\PTG" || GOTO PTG
ifmember "Domain\Finance" || GOTO Finance
ifmember "Domain\HR" || GOTO HR
REM end of nappy_d's edits

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
COGNOTECAuthor Commented:
this for a 2003 domain, SO I'd deed to install that ifmember on all of the DCs right?

I'll give that a blast and see how i get on
0
 
nappy_dCommented:
Yes, the ifmember.exe MUST be in the sysvol directory that contains your batch script.
0
 
COGNOTECAuthor Commented:
ok cool.  works locally I'll stick install ifmember on our DCs today and test it in the morning,.  thanks for the help
0
 
COGNOTECAuthor Commented:
thanks for you help much appreciated.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now