Jump to content

Ethernet renaming


iXô
 Share

Recommended Posts

I didn't know netsh, but your command don't exist.

Anything else ?

hmm... what OS are you using..?

are you running it from DOS Prompt?

or

Run(@ComSpec & " /c " & 'netsh interface set interface name="LAN" newname="Local Area Connection"', "")
Edited by Joon
Link to comment
Share on other sites

Ok, sorry, I made a mistake whith netsh I can rename a connection.

BUT my autoit script must run anywhere and I can't know in advance the name of the connection to rename.

How can I retreive the actual name of a connection and after call netsh with a autoit variable ?

like :

Dim $lan = ""
$lan = magicFunction()

Run(@ComSpec & " /c " & 'netsh interface set interface name="' & $lan &'" newname="Local Area Connection"', "")
Link to comment
Share on other sites

How can I retreive the actual name of a connection and after call netsh with a autoit variable ?

This will give you an array with all the ethernet card names and renamed as Local Area Connection1, Local Area Connection2, Local Area Connection3, etc...

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

;Get Network Connection Names
$base = "HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
While 1
    $i += 1
    $key = RegEnumKey($base, $i)
    If @error <> 0 Then ExitLoop
    $name = RegRead($base & "\" & $key & "\Connection", "Name")
    If StringLeft($key, 1) = "{" Then $lan &=  $name & "|"
WEnd
$lan = StringSplit(StringTrimRight($lan, 1), '|')

For $x = 1 To $lan[0]
    Run(@ComSpec & " /c " & 'netsh interface set interface name="' & $lan[$x] &'" newname="Local Area Connection"' & $x, "", @SW_HIDE)
NextoÝ÷ Øhm¶§h§v,ÛM4«'zÛ!²aÊ'{
+­­ºÈ§w­²®¶­sdFÒb33c¶Âb33c¶&6RÂb33c¶¶WÂb33c´6÷VçBÒ £´vWBæWGv÷&²6öææV7FöâæÖW0¢b33c¶&6RÒgV÷C´´ÄÒb3#µ55DTÒb3#´7W'&VçD6öçG&öÅ6WBb3#´6öçG&öÂb3#´æWGv÷&²b3#·³DC3dSs"ÔS3#RÓ4RÔ$d3Ó$$S3ÒgV÷C°¥vÆR¢b33c¶³Ò¢b33c¶¶WÒ&VtVçVÔ¶Wb33c¶&6RÂb33c¶¢bW'&÷"fÇC²fwC²FVâWDÆö÷¢b7G&ætÆVgBb33c¶¶WÂÒgV÷C·²gV÷C²FVà b33c´6÷VçB³Ò &Vuw&FRb33c¶&6RfײgV÷C²b3#²gV÷C²fײb33c¶¶WfײgV÷C²b3#´6öææV7FöâgV÷C²ÂgV÷C´æÖRgV÷C²Âb33µ$Tuõ5¢b33²Âb33´Æö6Â&V6öææV7Föâb33²fײb33c´6÷VçB VæD`¥tVæ@

Edit: added another way without using netsh, but you will need admin rights.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

THANKS FOR ALL !

this forum and autoit is really great.

I have done some modifications :

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

;Get Network Connection Names
$base = "HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
While 1
    $i += 1
    $key = RegEnumKey($base, $i)
    If @error <> 0 Then ExitLoop
    $name = RegRead($base & "\" & $key & "\Connection", "Name")
    $type = RegRead($base & "\" & $key & "\Connection", "PnpInstanceID")
    If StringLeft($key, 1) = "{" Then
        If StringLeft($type, 4) = "PCI\" Or StringLeft($type, 8) = "ROOT\NET" Then
            $lan &=  $name & "|"
        EndIf
    EndIf
WEnd
$lan = StringSplit(StringTrimRight($lan, 1), '|')


For $x = 1 To $lan[0]
     Run(@ComSpec & " /c " & 'netsh interface set interface name="' & $lan[$x] &'" newname="Local Area Connection"' & $x, "", @SW_HIDE)
Next

Because else it will rename also some connections that are not visible in the network panel.

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
 Share

  • Recently Browsing   0 members

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