Jump to content

what's the system variable to tcp/ip?, need to add to a batch file


ceez

Recommended Posts

hello fellow msfn-ers!

i just have a quick Q, what is (or is there) a system variable that returns the value of the machines ip address? you know, kinda like %computername%, %tmp%, %date%, etc...

i've googled my q, but no results apply :(

thanks,

ceez

:thumbup

Link to comment
Share on other sites


There is not a variable for the IP Address out of the box. You can see all the variables from a command prompt by typing SET.

I suppose you could add a computer startup script (in a GPO?) to automatically set a variable on each boot.

Just remembered this utility:

http://www.jsifaq.com/SF/Tips/Tip.aspx?id=4445

You could use it from the startup script by calling:

for /f "Tokens=*" %%i in ('techops /ip') do set IP=%%i

Of course there is always VBScript. Or any scripting language of your choice.

Edited by BlkCrowe
Link to comment
Share on other sites

ipconfig works great if only one connection is etablished ...

If there is two or more connections, there are more IP, more complicated to treat ...

But you can pickup just the ip begin with 192.168. for example :

@echo off
for /f "tokens=2 delims=:" %%? in ('ipconfig^|find "Adresse IP"^|find "192.168."') do set ip=%%?
set ip=%ip:~1%
echo IP : %ip%
pause

edit: Replace "Adresse IP" by your language, try ipconfig and look the text ... (Adresse IP is for French version)

Link to comment
Share on other sites

hey everyone, thanks for your input.... @ nitroshift, I second that motion....I am also CR/-\[]D at scripting!

@sonic, I'll look into that batch command. will that set a variable in the system so everytime I go to start-run and type %ip% it will return the system IP? this way I can freely use the %ip% variable in any other situation that might come up?

thanks again everyone!

ceez

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...