Solved

Run Win 7 native VPN from command line for particular networks

Posted on 2014-10-30
4
172 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
4 Comments
 
LVL 68

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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

First some basics on Windows 7 Backup.  It has 2 components one is a file based backup which is stored in .zip files each zip is split at around 200 Megabytes and there is the Image Backup which is as the name implies a total image of the partition …
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

17 Experts available now in Live!

Get 1:1 Help Now