Thursday, April 20, 2006

SCRIPT: Check if a user is a member of a specified group

IfMember is a command-line tool that checks whether the current user is a member of a specified group. It is typically used in Windows logon scripts and other batch files. IfMember uses its own process token to discover group membership, rather than querying the relevant domain controller each time it runs. While this has a significant performance benefit, it does mean that IfMember will only be aware of groups on the local computer, on the computer's domain, and on trusted domains. Remember to copy the file in the NETLOGON directory if you planning to use as login script.
Donwload IFMEMBER

Example:

IFMEMBER SITE1
IF ERRORLEVEL 1 GOTO SITE1

IFMEMBER SITE2
IF ERRORLEVEL 1 GOTO SITE2

GOTO END

:SITE1
net use J: \\SERVER1\User$\%username% /PERSISTENT:YES
rundll32 printui.dll,PrintUIEntry /in /n \\SERVER1\HP4050
rundll32 printui.dll,PrintUIEntry /y /n \\SERVER1\HP4050
GOTO END

:SITE2
net use J: \\SERVER2\User$\%username% /PERSISTENT:YES
rundll32 printui.dll,PrintUIEntry /in /n \\SERVER2\HP9000
rundll32 printui.dll,PrintUIEntry /y /n \\SERVER2\HP9000
GOTO END

:END
EXIT

No comments: