We help IT Professionals succeed at work.

Route Add command in login script

Kevin Smith
Kevin Smith asked
on
Medium Priority
5,700 Views
Last Modified: 2008-05-07
I have a login script that maps network drives and printers, can I add a standard command prompt that runs a ROUTE ADD command, or do I need to do it in another file and call the file to run in the vbs script?

Thanks!
Kevin
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2005

Commented:
You should be able to run it directly from the script.

ROUTE ADD ..


Author

Commented:
Cool...also, is it better to do that from a script, or just make the command persistant on each workstation (upped the points by 25 for the added question?

Commented:
You should be fine to add it to the logon Script.
What do you need an additional route in a workstation for?  Shouldn't your Layer 3 networking equipment be taking care of this?

Author

Commented:
My Firebox isn't accepting my routing table for some reason and time is an issue...I'm using the route add as a quick and dirty method of getting an application to work so it'll give me time to figure out the Firebox issue.
CERTIFIED EXPERT
Top Expert 2005

Commented:
I wouldn't make it persistent, no.  It'll run each logon so that takes care of having it there each time.  At some point you will correct the switch problem and at that point rather than deleting persistent routes you simply have to remove the line from the script.

Author

Commented:
I get an error when I add it directly in the vbs script...??
CERTIFIED EXPERT
Top Expert 2005
Commented:
You didn't mention it was VBScript.

You can't call it directly in VBScript since this a an External command from the scripting engine.

This snipit should do it.  Just change the details in the route.


Set objShell = WScript.CreateObject("WScript.Shell")
wscript.sleep 100
Set objExecObject = objShell.Exec("%comspec% /c route add 192.168.0.0 mask 255.255.255.0 0.10.10.10 ")


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2005

Commented:
My apologies - you did mention VBScript and I missed that.

The above should sort you out.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.