Ipconfig Description

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Vox
Posts: 4
Joined: 25 Oct 2010 06:53

Ipconfig Description

#1 Post by Vox » 25 Oct 2010 07:02

Hello,

I'm writing a script to check what ip number a computer has. This is what i have.

@echo off
ipconfig | find /i "10.160" | find /i "ip" >nul
if %errorlevel%==0 goto install

This script is working, the only thing is i want to check if the ip numer is from a vpn connection. Now i know that ipconfig /all shows also the discription.
But how can i show the ip-number of a network adaptor with the discription "Cisco VPN adaptor"?

so what i want is If a network adaptor has the discription "Cisco VPN" show the IP-adres.

I hope you understand what i want:)

Thanks in advance

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Ipconfig Description

#2 Post by amel27 » 25 Oct 2010 19:50

Vox wrote:so what i want is If a network adaptor has the discription "Cisco VPN" show the IP-adres.

via IPCONFIG:

Code: Select all

@echo off

for /f "skip=1 tokens=2 delims=:" %%a in  (
'ipconfig /all^|findstr /ibrc:" *Description .* Cisco VPN$" /c:" *IP Address"') do if not defined IPAddress (
for /f "tokens=*" %%b in ("%%a") do set "IPAddress=%%b")

echo %IPAddress%
pause>nul

via WMIC:

Code: Select all

@echo off

for /f "skip=1 delims={}" %%a in (
'wmic nicconfig where Description^="Cisco VPN" get IPAddress'
) do if not defined IPAddress set IPAddress=%%~a

echo %IPAddress%
pause>nul

Vox
Posts: 4
Joined: 25 Oct 2010 06:53

Re: Ipconfig Description

#3 Post by Vox » 26 Oct 2010 07:11

Yesss:D Thank you i used the WMIC solution, and it worked like a charm:)

Post Reply