Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run Win 7 native VPN from command line for particular networks

Posted on 2014-10-30
4
Medium Priority
?
193 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
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 …
Suggested Courses

963 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