Python Forum
How to rename Network Interface name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to rename Network Interface name
#7
if using 3.6+ use f-strings
subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', f'newname="{changeName}"'])
if using lower version
subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', 'newname="{}"'.format(changeName)])
for greater readability you may want to make this before the call
import subprocess

change_name = input("Enter the Interface name:")
new_name = 'newname="{}"'.format(change_name) # new_name = f'newname="{change_name}"'
subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', new_name])
subprocess.run(['netsh', 'interface', 'show', 'interface'])
don't use os.system - it's depreciated, use subprocess.call or even better subprocess.run
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: How to rename Network Interface name - by buran - Jan-30-2019, 04:54 PM
RE: How to rename Network Interface name - by buran - Jan-30-2019, 05:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  os.system("netsh interface set interface 'Wi-Fi' enabled") aniyanetworks 12 10,409 Jan-18-2019, 04:07 AM
Last Post: aniyanetworks

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020