Logon Script


D

Dan

Anyone know why I couldn't do something like this in my
(.bat) logon script? I'm seeing what appears to be the
net use /delete command not finishing before the next
command begins. I'm doing this in case a user is a
member of both of the groups so as to avoid a conflict of
the same drive letter attempting to be mapped twice and
producing an error.

:sales
@echo off
ifmember "salesuser"
if not errorlevel 1 goto ops
echo Connecting to Sales Share...
net use /delete q:
net use q: \\server\sales

:blush:ps
@echo off
ifmember "opsuser"
if not errorlevel 1 goto HR
echo Connecting to Ops Share...
net use /delete q:
net use q: \\server\ops

So in a nutshell, if a user is a member of both groups I
don't want any errors to pop up (specifically, taking out
the net use /delete q: command will hang the script and
error with System error 85 which means the drive letter
is already taken). This only occurs if the user is a
member of both groups. Can I get around this any other
way?

Thanks,
Dan
 
Ad

Advertisements

D

Deji Akomolafe

if exist Q: echo "drive exists"& net use Q: /delete /y
net use Q: \\server\sales

--

Sincerely,
Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I
Microsoft MVP - Directory Services
www.readymaids.com - we know IT
www.akomolafe.com
Do you now realize that Today is the Tomorrow you were worried about
Yesterday? -anon
 
C

Cary Shultz [A.D. MVP]

Dan,

I might just get away from the old-school .bat or .cmd logon scripts and use
..vbs and GPO. You can take a look at http://www.rlmueller.net and get his
'group-membership' logon scripts.

I have used this as well as kixtart to map network drives according to group
membership. I have never used ifMember. Well, not in a really long time!
However, that is not to say that you could not use ifMember.....

Is this a real situation? Is there any possibility that someone could be in
both the Sales and Ops group? Seems a little bit unlikely! Or is this just
a bad example?

--
Cary W. Shultz
Roanoke, VA 24012
Microsoft Active Directory MVP

http://www.activedirectory-win2000.com
http://www.grouppolicy-win2000.com
 
D

Dan

Hey Deji,
I tried this already and I get the same results, did you try this?
If Q: is mapped the drive does get deleted; however, when the next
piece of the script attempts to map Q: again the script hangs. Any
other ideas?
Thanks,
Dan
 
Ad

Advertisements

D

Deji Akomolafe

from my vantage point here, those 2 lines work. The "if exist" part is just
a check to see that Q is actually maped to something already. If it is, it
gets deleted and the script goes to the next line. If it's not, the script
does nothing and goes to the next line. You may have some logic problems in
the code.

Why don't you put in some checkpoints into your code, like this:
net use
pause ---this will let you see what drives are mapped to where and the
script waits for you to press a key to continue
if exist q: echo "Q driver exists!!!!"& net use Q: /delete /y
if exist q: echo "there is a problem. Q drive just won't go away!!!!"
pause
net use q: \\server\sales
pause
net use

or something along that line.
--

Sincerely,
Dèjì Akómöláfé, MCSE+M MCSA+M MCP+I
Microsoft MVP - Directory Services
www.readymaids.com - we know IT
www.akomolafe.com
Do you now realize that Today is the Tomorrow you were worried about
Yesterday? -anon
Hey Deji,
I tried this already and I get the same results, did you try this?
If Q: is mapped the drive does get deleted; however, when the next
piece of the script attempts to map Q: again the script hangs. Any
other ideas?
Thanks,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top