OVH Cloud OVH Cloud

@IP en variable

2 réponses
Avatar
Tyros
Hello,
J'ai besoin de récupérer mon adresse ip (dynamique) afin de l'incorporer
dens un script. Est-ce que quelqu'un sait comment récupérer cette valeur en
variable ?

Merci d'avance

2 réponses

Avatar
Thierry DEMAN [MVP]
Bonsoir,

voici un petit exemple!


ipconfig /All |find /I "adresse" |Find /I "IP" >c:tempip.txt
for /F "delims=: tokens=2 " %%i in (c:tempip.txt) do set noip=%%i

set noip= 192.168.1.2

Il y aura plusieurs résultats (si il y a plusieurs cartes réseaux!)

A+
--
Thierry DEMAN-BARCELÒ
MVP Exchange,SQL/Server
FAQ Exchange: http://faqexchange.dyndns.org
Site personnel: http://webfamilial.dyndns.org/thierry/pageprincipale.htm


"Tyros" a écrit dans le message de news:
caevco$84t$
Hello,
J'ai besoin de récupérer mon adresse ip (dynamique) afin de l'incorporer
dens un script. Est-ce que quelqu'un sait comment récupérer cette valeur
en

variable ?

Merci d'avance




Avatar
Jean-Claude BELLAMY
Dans le message news:caevco$84t$ ,
Tyros s'est ainsi exprimé:

Hello,
J'ai besoin de récupérer mon adresse ip (dynamique) afin de
l'incorporer dens un script. Est-ce que quelqu'un sait comment
récupérer cette valeur en variable ?


En VBS, c'est facile à faire :

set IPConfigSet GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE
IPEnabled=TRUE")
for each IPConfig in IPConfigSet
adrIP=IPConfig.IPAddress
min=LBound(adrIP)
max=UBound(adrIP)
For i = min To max
curadr­rIP(i)
If len(curadr)>0 Then wscript.echo curadr
Next
next
Wscript.quit




--
May the Force be with You!
La Connaissance s'accroît quand on la partage
----------------------------------------------------------
Jean-Claude BELLAMY [MVP] - http://www.bellamyjc.org
http://www.bellamyjc.org *