Solved

Run Win 7 native VPN from command line for particular networks

Posted on 2014-10-30
4
185 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 70

Accepted Solution

by:
Qlemo earned 500 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

What, When and Where - Security Threats from Q1

Join Corey Nachreiner, CTO, and Marc Laliberte, Information Security Threat Analyst, on July 26th as they explore their key findings from the first quarter of 2017.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

626 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