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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with ifmember and a login script to map drives

Status
Not open for further replies.
Apr 18, 2002
102
US
Not sure if this is the right forum...

I wrote this script (more like plagerized from various sources) to map drives based on group membership. The top part of the script runs fine. But once the script gets to the ifmember statements it just scrolls right through them to the end and no drives are mapped no matter the group membership. Been beating my head against the wall on this one. Can someone point out something I am missing?

net time \\DomController /set /y
net use o: /delete
net use s: /delete
net use s: \\Server\departments
\\AVServer\ofcscan\autopcc.exe
IF NOT EXIST %windir%\IFMEMBER.EXE copy \\DomController\netlogon\ifmember.exe %windir%

:"Auburn WA"
ifmember.exe "Auburn WA"
if not errorlevel 1 goto "Dallas TX"
net use o: \\Server\auburn
goto quit

:"Dallas TX"
ifmember "Dallas TX"
if not errorlevel 1 goto "Phoenix AZ"
net use o: \\Server\Dallas
goto quit

:"Phoenix AZ"
ifmember "Phoenix AZ"
if not errorlevel 1 goto "Central Florida FL"
net use o: \\Server\Phoenix
goto quit

:"Central Florida FL"
ifmember "Central Florida FL"
if not errorlevel 1 goto "Sacromento CA"
net use o: \\Server\Centralflorida
goto quit
 
Your logic is backwards. If the errorlevel is "not" 1 (not 1 = 0), it usually means the command succeeded, i.e. the user IS a member of that group resulting in an errorlevel = 0.

What you're doing is saying if the user is a member of group X, goto group Y. That's backwards from what you seem to want to accomplish, and is the reason why every mapping is skipped and eventually the script just goes to "quit."

It's also possible that the ifmember command does not throw 1 or 0 errorlevels, but different ones based on the output. Check the command help to see if that's true. I'm leaning towards the sole problem being the logic, though.

The solution is simply to remove the "nots.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top