If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
Enable and Disable Connection to Router
I want to create a script to enable or disable the connection of my PC
to my router. What routine handles this? -- David E. Ross http://www.rossde.com/ Yes, George Washington, Thomas Jefferson, and other "founding fathers" owned slaves. However, they created a nation. Robert E. Lee, Jefferson Davis, Thomas "Stonewall" Jackson and other "heroes" of the Confederacy tried to tear the nation apart. Statues and other monuments to those "heroes" of the Confederacy actually celebrate traitors and treason. See my http://www.rossde.com/editorials/edtl_conf_flag.html. |
Ads |
#2
|
|||
|
|||
Enable and Disable Connection to Router
David E. Ross wrote:
I want to create a script to enable or disable the connection of my PC to my router. What routine handles this? Create shortcuts or batch files that run (in one command line, no wrap): C:\Windows\System32\netsh.exe interface set interface "Local Area Connection" DISABLED C:\Windows\System32\netsh.exe interface set interface "Local Area Connection" ENABLED The connectoid's name is within double-quotes. Go into your network settings to see that is your connectoid's name to your router. |
#3
|
|||
|
|||
Enable and Disable Connection to Router
David E. Ross wrote:
Yes, George Washington, Thomas Jefferson, and other "founding fathers" owned slaves. However, they created a nation. Robert E. Lee, Jefferson Davis, Thomas "Stonewall" Jackson and other "heroes" of the Confederacy tried to tear the nation apart. Statues and other monuments to those "heroes" of the Confederacy actually celebrate traitors and treason. Traitors and treason are flexible terms. They only apply if you lose. George Washington and Thomas Jefferson were "traitors" until they won, then they were "Heroes" and "founding fathers". -- GW Ross |
#4
|
|||
|
|||
Enable and Disable Connection to Router
"David E. Ross" wrote
|I want to create a script to enable or disable the connection of my PC | to my router. What routine handles this? | I don't have an answer, but the first place I'd look is with RunDLL. There are examples he http://www.robvanderwoude.com/rundll.php As you may know, MS created RunDLL to call functions in system DLLs, typically with special parameters, in order to allow system automation. But I don't see a "disable network" option. A second possibility might be the last item on this page: https://autohotkey.com/board/topic/1...ing-dll-calls/ It's an AutoIt version of a Windows script. I tried a VBS version but it doesn't seem to work. The Shell.Application object is a funky piece of work and many things don't work properly. I got stumped at trying to find the collection of Verbs for network connections. That doesn't surprise me. The "verbs" never seem to have worked properly. |
#5
|
|||
|
|||
Enable and Disable Connection to Router
Mayayana wrote:
"David E. Ross" wrote |I want to create a script to enable or disable the connection of my PC | to my router. What routine handles this? | I don't have an answer, but the first place I'd look is with RunDLL. There are examples he http://www.robvanderwoude.com/rundll.php As you may know, MS created RunDLL to call functions in system DLLs, typically with special parameters, in order to allow system automation. But I don't see a "disable network" option. A second possibility might be the last item on this page: https://autohotkey.com/board/topic/1...ing-dll-calls/ It's an AutoIt version of a Windows script. I tried a VBS version but it doesn't seem to work. The Shell.Application object is a funky piece of work and many things don't work properly. I got stumped at trying to find the collection of Verbs for network connections. That doesn't surprise me. The "verbs" never seem to have worked properly. There are some commands here, for disabling individual network interfaces. There's a wmic one, a netsh one, and a powershell applet. https://www.petri.com/3-ways-disable...ion-windows-10 Paul |
#6
|
|||
|
|||
Enable and Disable Connection to Router
On 17/09/2017 03:26, David E. Ross wrote:
I want to create a script to enable or disable the connection of my PC to my router. What routine handles this? This is the most stupidest question I have seen for a very long time. Why do people resort to scripts when there are switches on the Windows UI to do simple things like this. For example this switch has always been available since the days of XP. I guess it was available in 95, 98 and 2000 but I have never used those OSs. They were before my time. https://i.imgur.com/v5i3Z6D.png https://i.imgur.com/v5i3Z6D.png It is time people become more practical and try to use the switches as much as possible because that is what they are for. They are not made for decoration or for Bill Gates' pleasure. -- With over 500 million devices now running Windows 10, customer satisfaction is higher than any previous version of windows. |
#7
|
|||
|
|||
Enable and Disable Connection to Router
On Sun, 17 Sep 2017 10:17:48 -0400, Mayayana wrote:
"David E. Ross" wrote |I want to create a script to enable or disable the connection of my PC | to my router. What routine handles this? | Possibly I don't fully understand this issue, or what I do isn't suitable, but, in W7, I made a shortcut to Local Area Connection and placed it on the Quick Launch Bar. Clicking on it brings up the Status with one of the buttons being Disable. I can check if it has worked on the Networx graph as the progress stops. I don't have an answer, but the first place I'd look is with RunDLL. There are examples he http://www.robvanderwoude.com/rundll.php As you may know, MS created RunDLL to call functions in system DLLs, typically with special parameters, in order to allow system automation. But I don't see a "disable network" option. A second possibility might be the last item on this page: https://autohotkey.com/board/topic/1...ing-dll-calls/ It's an AutoIt version of a Windows script. I tried a VBS version but it doesn't seem to work. The Shell.Application object is a funky piece of work and many things don't work properly. I got stumped at trying to find the collection of Verbs for network connections. That doesn't surprise me. The "verbs" never seem to have worked properly. -- Peter. The gods will stay away whilst religions hold sway |
#8
|
|||
|
|||
Enable and Disable Connection to Router
PeterC wrote:
Mayayana wrote: "David E. Ross" wrote I want to create a script to enable or disable the connection of my PC to my router. What routine handles this? Possibly I don't fully understand this issue, or what I do isn't suitable, but, in W7, I made a shortcut to Local Area Connection and placed it on the Quick Launch Bar. Clicking on it brings up the Status with one of the buttons being Disable. I can check if it has worked on the Networx graph as the progress stops. What if the OP wants to use commands (in a script) to do the enable or disable of his network connectoid when the OP is *not* around, like for a scheduled task? Your method requires more than clicking on the shortcut. You then have to click an object within the dialog to effect the disable. Also, my recollection of using a shortcut to show the properties of the LAN connectoid is that you only got a Disable button. Once disabled, you could not use the same shortcut to [re]enable that connectoid. Say you go to Control Panel - Network and Internet - Network Connections and drag the LAN connectoid to the desktop. Double-click on that shortcut (which references a GUID for connectoid, not a command to run with parameters). You'll see the status dialog with a Disable button. Click on the Disable button. Exit that dialog and use the shortcut again. Is there an Enable button now in that dialog so you can reenable to previously same disabled connectoid? I'll let you test. In the past, I remember I could easily disable but reenabling required work, like creating a new connectoid again. To use some GUI-only method, you could right-click on the network tray icon in the Windows taskbar's notification area, select "Open Network and Sharing Center", and click on the "Connect or disconnect" link there. Disconnect (disable) is easy: you kill the current connectoid. However, [re]connect (enable) is harder: you have to walk through wizards to define a new connectoid. Much easier to create shortcuts to the commands that I mentioned. After disabling, it's pretty easy to [re]enable. Since the OP wants to do the enable/disable within scripts, those same commands can be used in those. If you ever rename the connectoid (interface), you'll have to update the command to also use the new name. |
#9
|
|||
|
|||
Enable and Disable Connection to Router
"PeterC" wrote
| Possibly I don't fully understand this issue, or what I do isn't suitable, | but, in W7, I made a shortcut to Local Area Connection and placed it on the | Quick Launch Bar. Clicking on it brings up the Status with one of the | buttons being Disable. I don't understand it, either. I'm assuming the desire is to avoid any more than one click. (You have to click twice! How do you find time to get anything else done?! I have my cable running through a GPS on the desk. I literally unplug it when I'm not online. It's actually faster and easier than going through Network Connections. But of course it only works for a hard-wired desktop. |
#10
|
|||
|
|||
Enable and Disable Connection to Router
On Mon, 18 Sep 2017 04:31:27 -0500, VanguardLH wrote:
What if the OP wants to use commands (in a script) to do the enable or disable of his network connectoid when the OP is *not* around, like for a scheduled task? Your method requires more than clicking on the shortcut. You then have to click an object within the dialog to effect the disable. Also, my recollection of using a shortcut to show the properties of the LAN connectoid is that you only got a Disable button. Once disabled, you could not use the same shortcut to [re]enable that connectoid. Say you go to Control Panel - Network and Internet - Network Connections and drag the LAN connectoid to the desktop. Double-click on that shortcut (which references a GUID for connectoid, not a command to run with parameters). You'll see the status dialog with a Disable button. Click on the Disable button. Exit that dialog and use the shortcut again. Is there an Enable button now in that dialog so you can reenable to previously same disabled connectoid? I'll let you test. In the past, I remember I could easily disable but reenabling required work, like creating a new connectoid again. To use some GUI-only method, you could right-click on the network tray icon in the Windows taskbar's notification area, select "Open Network and Sharing Center", and click on the "Connect or disconnect" link there. Disconnect (disable) is easy: you kill the current connectoid. However, [re]connect (enable) is harder: you have to walk through wizards to define a new connectoid. If you have to define a new connectoid, I believe it means you deleted the previous connectoid, rather than simply disabling it. I don't recommend deleting when the intent is only to disable. Much easier to create shortcuts to the commands that I mentioned. After disabling, it's pretty easy to [re]enable. Since the OP wants to do the enable/disable within scripts, those same commands can be used in those. If you ever rename the connectoid (interface), you'll have to update the command to also use the new name. Agreed, the commands are fine, especially if the situation is meant to be non-interactive. -- Char Jackson |
#11
|
|||
|
|||
Enable and Disable Connection to Router
On Mon, 18 Sep 2017 04:31:27 -0500, VanguardLH wrote:
PeterC wrote: Mayayana wrote: "David E. Ross" wrote I want to create a script to enable or disable the connection of my PC to my router. What routine handles this? Possibly I don't fully understand this issue, or what I do isn't suitable, but, in W7, I made a shortcut to Local Area Connection and placed it on the Quick Launch Bar. Clicking on it brings up the Status with one of the buttons being Disable. I can check if it has worked on the Networx graph as the progress stops. What if the OP wants to use commands (in a script) to do the enable or disable of his network connectoid when the OP is *not* around, like for a scheduled task? Your method requires more than clicking on the shortcut. You then have to click an object within the dialog to effect the disable. Also, my recollection of using a shortcut to show the properties of the LAN connectoid is that you only got a Disable button. Once disabled, you could not use the same shortcut to [re]enable that connectoid. Say you go to Control Panel - Network and Internet - Network Connections and drag the LAN connectoid to the desktop. Double-click on that shortcut (which references a GUID for connectoid, not a command to run with parameters). You'll see the status dialog with a Disable button. Click on the Disable button. Exit that dialog and use the shortcut again. Is there an Enable button now in that dialog so you can reenable to previously same disabled connectoid? I'll let you test. In the past, I remember I could easily disable but reenabling required work, like creating a new connectoid again. OK, so far more complex than I'd realised. I'just tried it ; click icon, click Disable, connection stopped. Click icon, connection started (no dialogue box), so 3 clicks for 2 actions - not too bad. To use some GUI-only method, you could right-click on the network tray icon in the Windows taskbar's notification area, select "Open Network and Sharing Center", and click on the "Connect or disconnect" link there. Disconnect (disable) is easy: you kill the current connectoid. However, [re]connect (enable) is harder: you have to walk through wizards to define a new connectoid. Much easier to create shortcuts to the commands that I mentioned. After disabling, it's pretty easy to [re]enable. Since the OP wants to do the enable/disable within scripts, those same commands can be used in those. If you ever rename the connectoid (interface), you'll have to update the command to also use the new name. -- Peter. The gods will stay away whilst religions hold sway |
#12
|
|||
|
|||
Enable and Disable Connection to Router
On 9/16/2017 10:26 PM, David E. Ross wrote:
I want to create a script to enable or disable the connection of my PC to my router. What routine handles this? How about a batch like the following: ================================================== = :: _Net_Stop_Start.bat @ECHO OFF :: Change CMD Window title, size, and position :: ================================================== ============== SETLOCAL ENABLEEXTENSIONS & (TITLE _Network_Stop_Start.bat) & ENDLOCAL START "" /WAIT "C:\Program Files\nircmd-x64\nircmd.exe" win setsize stitle "Administrator" 400 200 600 500 netsh interface set interface "Local Area Connection" DISABLED ECHO( & ECHO Press any key to reconnect to Network & ECHO( & PAUSE NUL netsh interface set interface "Local Area Connection" ENABLED ECHO( & ECHO Network has been reconnected" & ECHO( & Timeout 5 EXIT ================================================== ============= The first commands set window size and placement. Run batch to Disable and then click in window to Enable. -- Zaidy036 |
Thread Tools | |
Display Modes | Rate This Thread |
|
|