Solved

Need help with Script

Posted on 2014-02-19
6
291 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
[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
  • 3
  • 2
6 Comments
 
LVL 36

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 36

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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 26

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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

636 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