Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add routes

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
how can i add routes with vbscript (.vbs) file.
the file should run
route add 12.12.12.12 255.255.254.0 IP
where IP is a variable which is set before
itried:
WSHShell.run "route add 12.12.12.12 255.255.254.0" & IP
but it didnt work=(
anyway, is there a very simple way to get the local ip to a variable? my code is VERY long and builds on the registry, i think there mus be a very short object, too, right?
 
Could the answer be as simple as:

WSHShell.run "route add 12.12.12.12 255.255.254.0 " & IP

In other words, add a space before the second quote above?

As for your second question, you can use the Winsock Control to retrieve the Local IP address.

You have to get tricky though, you can't allocate this control by using something like
Code:
CreateObject("MSWinsockLib.Winsock")
. You need to invoke it by its classid, which means changing your .vbs into a .wsf file, adding XML tags as shown in this example. The <object> tag can invoke the control by specifying its classid:
Code:
<job id=localip>
    <object id=&quot;objWS&quot; classid=&quot;clsid:248DD896-BB45-11CF-9ABC-0080C7E7B78D&quot; />
    <script language=&quot;vbscript&quot;>
        MsgBox objWS.LocalIP  
    </script>
</job>

To test this copy/paste the code above into a text file localip.wsf, then double-click on its icon.

Hope this helps.
 
no i tried it with the space and nothing happend. btw its win2k.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top