Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon script using if member

Status
Not open for further replies.

sgic

IS-IT--Management
Nov 3, 2000
7
0
0
US
I am trying to write a batch file that will map network drives according to what group the user is in. I am using the IFMEMBER.exe from the Resource kit. Here is part of the script.

:ACCT
@ifmember Accounting
@if not errorlevel 1 goto AGENTS
@net time \\bdc1 /set /yes
@net use e: /del
@net use e: \\bdc2\droot
@net use g: /del
@net use g: \\bdc2\pdq
@net use k: /del
@net use k: \\bdc1\rbc
@net use w: /del
@net use w: \\bdc1\droot
@net use x: /del
@net use x: \\imagessvr\imagewrt
@net use y: /del
@net use y: \\imagessvr\images


:AGENTS
@ifmember Agents
@if not errorlevel 1 goto AUDIT
@net time \\bdc1\ /set /yes
@net use x: /del
@net use x: \\imagessvr\imagewrt
@net use y: /del
@net use y: \\imagessvr\images

I am not sure if I am using the ERRORLEVEL correctlly. It does not map any drives when I put the "if not" line in. If the user is in the agents group, the errorlevel would be 1 correct??? Our users are in more than one group. Would the errorlevel keep going up or is it reset everytime. Any help would be greatly apperciated.
 
This probably doesn't help but I saw no problems with it. As a test, I created a quick batch file similar to yours but a tad simpler (I just had it echo certain words at the various levels). I then changed group names from true names to false names for my user account and it worked fine. I am on a W2K workstation and didn't use the @'s which may make a difference. Good luck.
 
a simple change might me instead of...

net use x: /del
net use x: \\imagessvr\imagewrt

try...

net use x: \\imagessvr\imagewrt /persistent:no

your 'if not' statements seem ok, but just for clarification you may want to use...

ifmember [domain]\[group]

i don't put the '\\' before the domain name, example...

ifmember domain\marketing
if not errorlevel 1 goto NEXTGROUP
net use m: \\server\mktg$ /persistent:no

:NEXTGROUP
.....

this is pretty much how i have mine setup...



Jason Wilder
IT/CAD Manager
"When I go, I want to go in my sleep like Grandpa. Not screaming in terror like his passengers."
 
Thanks for you help, but I think I found the problem. It seems like it only works for global groups. I ran a script to show the errorlevel.I checked for several groups, and it only counts the global groups. Are there any programs that will do what I need but use both local and global groups?
 
what do you mean local? local to a machine? local to the server? Jason Wilder
IT/CAD Manager
"When I go, I want to go in my sleep like Grandpa. Not screaming in terror like his passengers."
 
Local to the Domain. If you go into User Manager, under USER you have new Local group and new global group. If you have more than one domain you could only setup global groups to be trusted by another domain. Local groups can only be trusted by the domain they are in.

I like your grandpa saying LOL
 
You might consider using Kix32 (from the NT4 resource kit) to create your login scripts... you can check for group membership and do a lot of other neat stuff... Peter Van Eeckhoutte
peter.ve@pandora.be

 
The ifmember only works for NT/2000 machines. Win9x will not work using ifmember. I pounded my head against the PDC to get it to work for logon scripts, it didn't, but I did get a bruise! I went to kix32 and it worked great! You can get it at Good luck!!!



Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top