Logon script for a laptop user that roams between sites in a single Windows 2003 Domain

Posted on 2005-05-10
Last Modified: 2010-03-18
Hi All.

Here is the Situation:
Site A - Domain Controller A
Site B - Domain Controller B
A VPN connects the sites (DSL).

I have some laptop users that connect at either site A or B.

Is there some scripting I can implement to map drives and connect to printers and set defaut printers etc based upon what site that user is logged into?



Question by:PeteJH
    LVL 82

    Accepted Solution

    You can check in which subnet the notepad currently is, and branch as necessary, for example like this:

    if "%Subnet%"=="" goto Subnet1
    if "%Subnet%"=="" goto Subnet2
    goto :eof
    :: ...
    goto :eof
    :: ...

    The following batch script will calculate the current subnet (the real subnet, nut just based on octetts), and put it into the variable "%Subnet%":

    @echo off
    set TempFile=%Temp%\~ipconfig~.tmp
    ipconfig >"%TempFile%"
    for /f "tokens=2 delims=:" %%a in ('type "%TempFile%" ^| find /i "IP-Address"') do set IP=%%a
    for /f "tokens=2 delims=:" %%a in ('type "%TempFile%" ^| find /i "Subnet"') do set Mask=%%a
    del "%TempFile%"
    set IP=%IP: =%
    set Mask=%Mask: =%
    for /f "tokens=1-4 delims=." %%a in ("%IP%") do (
      set s1=%%a
      set s2=%%b
      set s3=%%c
      set s4=%%d
    for /f "tokens=1-4 delims=." %%a in ("%Mask%") do (
      set /a s1 "&=" %%a
      set /a s2 "&=" %%b
      set /a s3 "&=" %%c
      set /a s4 "&=" %%d
    set Subnet=%s1%.%s2%.%s3%.%s4%
    echo Local subnet: %Subnet%

    Author Comment

    Thanks for that. I will play around with it in the coming weeks and let you know how it goes.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
    The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now