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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

Need help with Script

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
Mike
Asked:
Mike
  • 3
  • 2
1 Solution
 
KimputerCommented:
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
 
MikeSecurityAuthor Commented:
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
 
KimputerCommented:
Yes you are on the right track (but still replace the XX). And the last echo off is also not necessary.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
Fred MarshallCommented:
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
 
MikeSecurityAuthor Commented:
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
 
MikeSecurityAuthor Commented:
Thank you
0

Featured Post

Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now