Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script or batch file to identify if travelling laptop is connected to it's local domain

Posted on 2009-06-29
3
Medium Priority
?
420 Views
Last Modified: 2013-12-24
I need a way to identify if a travelling user is connected to their local domain before running their login script.  This is to avoid installing software and updates across slow WAN links.

Perhaps identifcation by checking AD OU or subnet?


Cheers
Lachlan
0
Comment
Question by:Multimatic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 24737009

Here's an example of a routine you could use in a .bat to determine the subnet by using the default gateway
 

 

for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find "Gateway"') DO SET GW=%%a
if %GW%== 10.63.106.2 set GW=Location1
if %GW%== 10.63.106.130 set GW=Location2
if %GW%== 10.63.106.162 set GW=Location3
if %GW%== 10.63.106.194 set GW=Location4

Open in new window

0
 
LVL 10

Accepted Solution

by:
TakedaT earned 2000 total points
ID: 24737019
I have something running for this at my current job.  It depends on how your network is setup, but here is what I have running in my login scripts before any installs run.

Of course, it would need to be modified to suit your particular situation.
ipconfig /all | findstr /c:"IP Address" | findstr /c:"192.168.x.">nul && (
	goto install
)
ipconfig /all | findstr /c:"IP Address" | findstr /c:"172.16.x.">nul && (
	goto install
)
 
goto end
 
:install
(installs go here)
 
 
:end

Open in new window

0
 
LVL 1

Author Closing Comment

by:Multimatic
ID: 31597964
Super fast response and a very simple yet effective solution!

Cheers
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Make the most of your online learning experience.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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