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

x
?
Solved

Run Win 7 native VPN from command line for particular networks

Posted on 2014-10-30
4
Medium Priority
?
189 Views
Last Modified: 2014-11-24
I'm attempting to call the native win 7 client from command line but only when the user is not connected to any of our 40 or so internal networks. Calling the VPN client is fairly easy with rasdial but how would I go about writing the rest of the script checking for example for 192.168.0.0 /24, 192.168.1.0/24 etc. networks.

thanks
0
Comment
Question by:aackar
[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
4 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 40414628
This could get difficult, as you have so many networks to check for. And are you certain there is no "conflict" with a private LAN outside of your internal networks if we only check for IP addresses?

A simple check is something like this:
route print 192.168.* | find /v "Network Destination" > nul && rasdial OfficeVPN

Open in new window

A more precise way is to check for each single network:
route print | find "255.255.255.0" | findstr /v "192.168.1.0 192.168.2.0 192.168.4.0 192.168.7.0" >nul && rasdial OfficeVPN

Open in new window

It is also possible to use text file containing the networks to check for (with one network per line), and provide that with /G:filename instead of the literal list above.
0
 

Author Comment

by:aackar
ID: 40415691
I am confident we won't run into it since most private LANs come preconfigured with either 192.168.0.0/24 or 192.168.1.0/24 and we are not using those. I am yet to see a router from
Best Buy come with a different default IP scheme.
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 40462081
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

How to set-up an On Demand, IPSec, Site to SIte, VPN from a Draytek Vigor Router to a Cyberoam UTM Appliance. A concise guide to the settings required on both devices
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 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