Sign in to follow this  
Followers 0
ACalcutt

Getting network connection names

6 posts in this topic

#1 ·  Posted (edited)

i am trying to get network connection names so i can use netsh to change ip addreses

i found out the command "netsh inter ip show address"

will give a list of connections. but i dont know how to get the results of a dos command into a string that i can use

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I remember seeing something from beta that can read console output

OK, found it

here

Edited by Shibuya

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i will look at that....for a quick fix i did

#Include <process.au3>

Dim $line = 4

_RunDOS("netsh inter show interface > c:\connections.txt")

While 1

$text = FileReadLine("c:\connections.txt", $line)

If @error = -1 Then ExitLoop

If StringinStr($text, "Dedicated") Then MsgBox(0, "", StringTrimLeft($text, 47))

$line = $line + 1

WEnd

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

In the registry the names of network connections are stored under this key:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}

This contains subkeys with {CLSID}\Connection

In this you will find the key "Name". It contains the connection name.

You can read it out and display like this:

Dim $i, $base, $key, $name

$base = "HKLM\SYSTEM\ControlSet001\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}

Do 
    $i = $i + 1
    $key = RegEnumKey($base, $i)
    $name = RegRead($base & $key & "\Connection", "Name")
    If StringLeft($key, 1) = "{" Then MsgBox(0, "Connection " & $i, $name)
Until $key = ""

Regards,

Buffo

Share this post


Link to post
Share on other sites

the second solution is: look in the help of autoit

Read in a number of characters from the STDOUT stream of a previously run child process.

StdoutRead ( process_id[, count[, peek = false]] )

and check also related command! to see more use!

with this you can send any key to a cmd console or another process even if the windows is blind! and you can retrive data too.

and the other option is to look in the registry!

check this out! :

it will retrive all interface and say is name! this is a batch script. you can rewrite it easy in autoit!

the script tel you all key reg to be used for that and what key mean!

hope this help! bye bye!

How do I retrieve an interface {GUID}?

In order to be able to accommodate multiple network adapters, many networking settings are located in the registry under an interface {GUID} (Globally Unique IDentifier), such as:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces\Tcpip_{GUID}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PSched\Parameters\Adapters\{GUID}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters\{GUID}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DNSRegisteredAdapters\{GUID}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{GUID}\Parameters\Tcpip.
I have scripted InterfaceGUID.bat to retrieve the {GUID} based upon a connection name that you specify, such as Local Area Connection.
The syntax for using InterfaceGUID.bat is:

Call InterfaceGUID Name GUID

Where Name is the connection name, and GUID is a call directed environment variable that will contain the {GUID}, or none if the connection name cannot be found.

NOTE: InterfaceGUID.bat uses REG.EXE built into Windows XP, Windows Server 2003, and newer, or from the Windows 2000 Support Tools.

InterfaceGUID.bat contains:

@echo off
if {%2}=={} @echo Syntax InterfaceGUID Name GUID&goto :EOF
setlocal
set name=%1
set GUID=none
set key="HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
for /f "Tokens=*" %%i in ('reg query %key% /s^|Findstr /I /L /C:"}\Connection"') do (
 call :fndname "%%i"
)
endlocal&set %2=%GUID%
goto :EOF
:fndname
set conkey=%1
set conkey=%conkey:HKEY_LOCAL_MACHINE=HKLM%
for /f "Tokens=1,2*" %%a in ('reg query %conkey% /v Name^|findstr /I /L /C:%name%') do (
 call :setGUID
)
goto :EOF
:setGUID
set GUID=%conkey:"HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\=%
set GUID=%GUID:\Connection"=%

this code come from www.jsiinc.com very nice useful stuff about reg in windows! the better! we learn than in the course for MCSE hehe :P


GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for the help

i used the registry script from buffo

just a minor fix is... "$base & $key" should be "$base & "\" & $key"

"$name = RegRead($base & "\" & $key & "\Connection", "Name")"

I posted the script i made here

http://www.autoitscript.com/forum/index.php?showtopic=18760

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
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
Sign in to follow this  
Followers 0