?
Solved

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

Posted on 2005-05-10
4
Medium Priority
?
232 Views
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?

Thanks,

Pete

0
Comment
Question by:PeteJH
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 13968627
You can check in which subnet the notepad currently is, and branch as necessary, for example like this:

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

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

====8<----[Subnet.cmd]----
@echo off
setlocal
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%
====8<----[Subnet.cmd]----
0
 

Author Comment

by:PeteJH
ID: 13991894
Thanks for that. I will play around with it in the coming weeks and let you know how it goes.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nslookup is a command line driven utility supplied as part of most Windows operating systems that can reveal information related to domain names and the Internet Protocol (IP) addresses associated with them. In simple terms, it is a tool that can …
Enterprise networks where VoIP phones have been deployed frequently use port configurations that allow both a computer and an IP phone to be plugged into the same switch port but use different VLANs. On Cisco equipment I'm referring to the "native V…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

850 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