Hello,
Typically I don't have trouble finding a good way to execute this stuff in a batch file (usually I search the heck out of this site & others), but this one is confusing me a bit & I can't find many examples that are clicking for me today.
I have a good number of users I need to detect in a batch file (my list has ~20 users).
Based on the username or usernames, I want to execute net use drive mappings.
Typically I'd just make a unique batch file for each user, but the number of users I have keeps climbing & I'd like to start maintaining just 1 batch file for the whole list of users.
Here's what I've come up with so far when there's only 1 user in a group:
IF [NOT] "%username%"=="JohnDoe" GOTO NEXT1
@net use J: /delete
@net use J: "\\Not JohnDoe's Home Folder" /no
GOTO ENDIF
:NEXT1
IF [NOT] "%username%"=="JaneDoe" GOTO NEXT2
@net use J: /delete
@net use J: "\\Not JaneDoe's Home Folder" /no
GOTO ENDIF
:NEXT2
<repeat thru list of users>
:ENDIF
This should work fine, but it rapidly increases the number of lines in the file.
What I'd like to do is compare a group of people in 1 shot. Something like:
IF [NOT] "%username%"=="JohnDoe" OR "JaneDoe" OR "FredDoe" GOTO NEXT1
@net use K: /delete
@net use K: "\\Folder that all 3 users store files in" /no
GOTO ENDIF
:NEXT1
IF [NOT] "%username%"=="VIP1" OR "VIP2" OR "VIP3" GOTO NEXT1
@net use K: /delete
@net use K: "\\Folder that only VIP users store files in" /no
GOTO ENDIF
:NEXT2
<and so on and so forth>
:ENDIF
If it exists, does anyone have the correct syntax I should use to compare a group of usernames in this manner? Please let me know if I can clarify anything.