Jan-30-2019, 05:15 PM
(Jan-30-2019, 04:54 PM)buran Wrote: To disable Wi-Fi
>>> import subprocess >>> subprocess.call(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', 'admin="DISABLED"']) 0You need to run cmd in elevated mode (i.e. Run As Administrator)
Change the name if the adapter name is not Wi-Fi, e.g. Wireless Network Connection, etc.
Use this as example how to rename interface
>>> subprocess.call(['netsh', 'interface', 'set', 'interface', 'name="TPALAN"', 'newname="TPALAN2"'])
Perfect Thanks Buran.
One more questions: I am trying to get input function to get Interface name from User, but it doesn't accept input value. can you please help?
import subprocess import os changeName=input("Enter the Interface name:") print(changeName) subprocess.call(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', 'newname=changeName']) os.system("netsh interface show interface")
Output:Enter the Interface name:Wi-Fi123
Wi-Fi123
Admin State State Type Interface Name
-------------------------------------------------------------------------
Disabled Disconnected Dedicated changeName
Disabled Disconnected Dedicated TPALAN
Enabled Connected Dedicated TPALANDOC
Process finished with exit code 0
It doesn't accept the Value from Input function.Please help.
Thank you