Auto IP Batchfile

It’s kinda late in the build season, but I wanted to share this anyway

To switch to regular internet.

ECHO This fanciness is brought to you by Folders!
ECHO You may have to change the text in "Wireless Network Connection"

ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = "Wireless Network Connection" source = dhcp

netsh int ip show config


To switch to Robot.

ECHO This fanciness is brought to you by Folders!
ECHO You may have to change the text in "Wireless Network Connection"

set varip=
set varsm=

REM For the most up-to-date-info, visit

ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Wireless Network Connection" source = static addr = %varip% mask = %varsm%

netsh int ip show config


Oddly enough, I set up these same scripts last night for our DS and my programming lappy.

Only annoying bit is that it seems windows 7 won’t allow you to force running as administrator on them. Did you find any way around this (because right clicking and clicking run as admin is so terribly difficult :wink: )

Edit: Also, I thought the FRC subnet was typically rather than , was this intentional. Also as a note, I added set for “Local Area Connection” as well to a second IP, that way you can hop back and forth on wired at the same time

Not sure whether this works on batch files, though.

Thank you for sharing!

Our team has used this and loves it. We modified the toRobot script so that it prompts you for what you want your computer’s IP address to end in, since we often have multiple computers connected to the robot network and we want to prevent IP conflicts.

There are two ways to accomplish elevation via BATCH scripts.
1) Manifest file
You would need to convert the BAT script to an EXE. There are hundreds of programs and utilities to do that for you. One credible (but weird) method can be found here.

Finally, you need to embed a special elevation manifest file into that EXE. This article discusses the manifest’s contents for getting an elevated privileges prompt. Again, there’s some research involved, so beware. :slight_smile:

2) External launcher
The ShellExecute API, with the “runas verb”, will launch whatever program is in the arguments as an admin. I think there was a little EXE for exposing that API to BATCH scripters, but I seem to have lost it. Alternatively, if you know a little Python or a language that supports this API, you could create a program that exposes that API as well. (I’m a Python coder - if you need help for doing that, feel free to ask me and I’ll provide you with my code!)

However, I found this program online called “Elevate”:

I don’t know how trustworthy this is, but it looks like it does the job. :slight_smile:

If your team uses your Dlink in bridge mode, here is alternate solution to using the batch file:

configure your router (ours is the original blue, FRC provided linkysis) to automatically give out IP addresses like such via DHCP. Then you can program the robot and surf CD at the same time! :smiley:

Using the router + wired internet connection also helps get around school wireless issues.

I don’t know enough about Robot to Dlink communications to say if the same thing will work if you have your Dlink configured as access point.

A shortcut can be made to run as administrator, so when we made these files we just made shortcuts to them and set that. Of course, that leaves 8 files on the desktop ({wireless,ethernet} {DHCP,static} {batch file,shortcut}), but 4 of them could be moved somewhere else.

It’s kind of amazing the hoops windows makes you jump through to do what you want for “security” purposes.