Logon Script

Archived from groups: microsoft.public.win2000.active_directory (More info?)

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

:ops
@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
4 answers Last reply
More about logon script
  1. Archived from groups: microsoft.public.win2000.active_directory (More info?)

    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
    "Dan" <anonymous@discussions.microsoft.com> wrote in message
    news:0f7601c55111$39f21ef0$a501280a@phx.gbl...
    > 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
    >
    > :ops
    > @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
  2. Archived from groups: microsoft.public.win2000.active_directory (More info?)

    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


    "Dan" <anonymous@discussions.microsoft.com> wrote in message
    news:0f7601c55111$39f21ef0$a501280a@phx.gbl...
    > 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
    >
    > :ops
    > @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
  3. Archived from groups: microsoft.public.win2000.active_directory (More info?)

    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

    Deji Akomolafe wrote:
    > 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
    > "Dan" <anonymous@discussions.microsoft.com> wrote in message
    > news:0f7601c55111$39f21ef0$a501280a@phx.gbl...
    > > 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
    > >
    > > :ops
    > > @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
  4. Archived from groups: microsoft.public.win2000.active_directory (More info?)

    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
    "Dan" <dankennedy24@hotmail.com> wrote in message
    news:1115312074.459114.72830@g14g2000cwa.googlegroups.com...
    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

    Deji Akomolafe wrote:
    > 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
    > "Dan" <anonymous@discussions.microsoft.com> wrote in message
    > news:0f7601c55111$39f21ef0$a501280a@phx.gbl...
    > > 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
    > >
    > > :ops
    > > @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
Ask a new question

Read More

Command Prompt Windows