473,378 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

VB: Find default gateway and set persistent routes or output to a batch file.

I am fairly familiar with scripting dos commands and that's about it. I remember some syntax and whatnot from a few programming classes I've taken but I don't remember any of the modules or functions for VB at all.

Goal:
I need to set persistent routes for 2 ip address on a VPN that has a dynamic gateway each time it connects.

I am almost positive I can't script this with standard dos commands so I am wondering if VB will let me do this and if so how? If not, does anyone know of a way that I can? I am desperate for help here.

This is what the batch file would looks like in case it is any help:

ROUTE delete 10.12.12.96
ROUTE delete 10.22.12.83

ROUTE -p add 10.12.12.96 MASK 255.255.255.255 [dynamicGateway]
ROUTE -p add 10.22.12.83 MASK 255.255.255.255 [dynamicGateway]

If I can't use a function to pull the gateways I know I can output ipconfig to a text file and then possibly pull the gateway from that file if needed.

Thanks so much to anyone who can help.

Jeremy
Apr 18 '07 #1
4 4653
Killer42
8,435 Expert 8TB
I don't know much about the networking area, but at the very least you could have VB process that output text file and either issue the DOS commands or write the batch file dynamically then execute it.

Hopefully you'll be able to find a more elegant solution than that, though.
Apr 19 '07 #2
At this point I'm desperate for any solution. Right now I have her running a batch to output the ipconfig to a text file and copying the default gateway to the batch file that sets the persistent routes. It works but it isn't pretty. I just don't remember anything from my VB classes to help myself out i this situation.
Apr 19 '07 #3
Killer42
8,435 Expert 8TB
At this point I'm desperate for any solution. Right now I have her running a batch to output the ipconfig to a text file and copying the default gateway to the batch file that sets the persistent routes. It works but it isn't pretty. I just don't remember anything from my VB classes to help myself out i this situation.
If you post samples (suitably edited if there's anything confidential) of the IPCONFIG output text file and the batch file, I could throw together a quick little VB program you can use to put the required value into the batch file before you incoke it.
Apr 19 '07 #4
istiak
1
if you use it as a batch file you can easily add the route

@echo off
@(color 6A) & (@Title %title%)
@echo please wait...

::# Define a temp variable 'DefaultGateway'
@For /f "tokens=3" %%* in (
'route.exe print ^|findstr "\<0.0.0.0\>"'
) Do @Set "DefaultGateway=%%*"

::# Redirect output to a textfile
route add [Destination IP] mask [subnet mask] %DefaultGateway% -p
Apr 4 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically...
6
by: Wescotte | last post by:
I'm writing a tiny php app that will log into our bank of america account and retrieve a file containing a list of checks that cleared the previous day. The problem I'm running into is when I...
7
by: felecha | last post by:
I have been developing an app in VB.Net, using a simple form and a button to kick off a class that starts asynchronously receiving from a MessageQueue. It's been working fine, but now I'm moving...
0
by: pmclinn | last post by:
How do you grab a users default gateway? Connection-specific DNS Suffix . : ksde.local IP Address. . . . . . . . . . . . : 10.117.161.108 Subnet Mask . . . . . . . . . . . : 255.255.248.0...
8
by: Alan J. Flavell | last post by:
What I was trying to do: to offer a default stylesheet, plus another small stylesheet which can be applied additionally to the default one. Preferably, the optional stylesheet should be initially...
4
by: ed | last post by:
Hi all, I'm very new to vb (2nd day) and I need to create a small app that will replace my old batch file with a flashy gui. I had some experience with access 2.0 which helps ;) What I would...
7
by: Nananana | last post by:
Hi. I have 2 DB2 statements: connect select How can I create a batch file and redirect the output to a file? I would like something like this:
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
1
by: Mike Slinn | last post by:
The following short Python program parses a KML file and displays the names of all Marks and Routes: from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.