iXô Posted November 30, 2006 Posted November 30, 2006 Hello, I am quite new to autoit, and I love it ! But I have a question : on a computer I have to rename the 2 ethernet card, but I don't know how to do that. Can someone help me ? Thanks for all.
NeoFoX Posted November 30, 2006 Posted November 30, 2006 You mean this reg-key? HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\2 Key: Description Neo [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]
Joon Posted November 30, 2006 Posted November 30, 2006 Try using netsh. netsh interface set interface name="LAN" newname="Local Area Connection"
iXô Posted November 30, 2006 Author Posted November 30, 2006 I didn't know netsh, but your command don't exist. Anything else ?
Joon Posted November 30, 2006 Posted November 30, 2006 (edited) 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 November 30, 2006 by Joon
iXô Posted December 1, 2006 Author Posted December 1, 2006 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"', "")
Danny35d Posted December 1, 2006 Posted December 1, 2006 (edited) 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 December 1, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
iXô Posted December 1, 2006 Author Posted December 1, 2006 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.
Joon Posted December 1, 2006 Posted December 1, 2006 I don't think Windows 2000 has netsh so this one work without using netsh.Far as I know netsh was available from Windows 98 era.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now