Solved

Need help with Script

Posted on 2014-02-19
6
287 Views
Last Modified: 2014-03-05
Greeting Experts,

I am new to scripting and needs some help creating either a “VB script” or “Batch file” that can be used as a template. The purpose of the script is to make some changes to the routing table on a small number of computers (located on factory floors) that have no need for internet access.
What I am looking to do is create a simple script (i.e. template) that our Domain Admins can make changes on the routing table (i.e. route delete & route Add). Meaning the only thing they would need to change is the IP address of each route based sub-net/mask for each of the locations… I would appreciate any help with this problem…


Example of the routing table looking to use in the script template

Route Delete 0.0.0.0
Route add 10.40.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 170.146.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 97.107.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 10.20.XX.XX mask 255.255.255.0 10.25.XX.XX
0
Comment
Question by:amstoots
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 39870629
A batch file is the easiest way and the most readable and understandable.
Actually what you just typed is actually almost working (except for the XX's)
Just copy and paste it in notepad and save as a .bat file.
0
 

Author Comment

by:amstoots
ID: 39870654
OK.. that all I need to do.......I should have put this in the original question but didn't ... I looking to do it in stealth mode.... I have done some reading and found you can do something to the effect of following below.. (code below) . Am I on the right track...

Echo off 

Route Delete 0.0.0.0
Route add 10.40.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 170.146.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 97.107.XX.XX mask 255.255.255.0 10.25.XX.XX
Route add 10.20.XX.XX mask 255.255.255.0 10.25.XX.XX 

Echo off 

Open in new window

0
 
LVL 35

Expert Comment

by:Kimputer
ID: 39870670
Yes you are on the right track (but still replace the XX). And the last echo off is also not necessary.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 25

Accepted Solution

by:
Fred Marshall earned 500 total points
ID: 39870858
Here is a .bat file that should work.  Just change the variables to the addresses, masks that you want in each case: 1,2,3,4

NOTE: I added -p to make the routes persistent.  If you want them to disappear after a reboot then delete the -p entries.

This .bat file I believe requires that you run it under administrator privilieges.
One way to do that is to create a shortcut to the .bat file and then set the shortcut to run as administrator.

You have to change the file extension from .txt to .bat
route-add.txt
0
 

Author Comment

by:amstoots
ID: 39871440
Is there away to add a "Route Delete  XX.XX.XX.XX for the "-p" in the script in some way... I am just not sure how to work that.... ?
0
 

Author Closing Comment

by:amstoots
ID: 39907241
Thank you
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

861 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

23 Experts available now in Live!

Get 1:1 Help Now