Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

The Brotherhood 

Shut Off Networking / Wifi With Netsh (Windows)

[Image: header4.gif]

If you want to turn off wireless connections or other networking options, it's easy to do that with netsh. This is a Windows only tutorial, but Linux or Mac users could still use some of the examples at end of the guide for running commands via languages - but you would need to adjust it to not use netsh and instead use your native OS APIs and features instead.

First we will use a command that shows us the network profiles we've connected to in the past:

List All Network Profiles
Code
netsh wlan show profiles

Example response:
Code
All User Profile     : office-internal
    All User Profile     : Mandarin Oriental 2
    All User Profile     : Omni Guest
    All User Profile     : Home A107C

Disconnect From Current Network
Code
netsh wlan disconnect

Delete Specific Network Profile
Code
netsh wlan delete profile name="Home A107C"

Disable Computer Wireless Networking / Wifi
Code
netsh interface set interface \"Wi-Fi\" admin=disable

Disable Computer Ethernet / Wired Connections
Code
netsh interface set interface "Ethernet" admin=disabled

You may be required to use escalated, administrator permissions on the terminal when using it. Similarly, if you run the commands from another program then that program would need same permission level.

Here are some ways you can execute these commands via code:

C++
Code
#include <cstdlib>
system("netsh interface set interface \"Wi-Fi\" admin=disable");

PHP
PHP Code

<?php
exec
('netsh interface set interface "Wi-Fi" admin=disable');
?>

Python
Code
import subprocess
subprocess.run('netsh interface set interface "Wi-Fi" admin=disable', shell=True)



The three above are tested by me and have been used in past to run other commands. The code below is not tested, but I asked GPT to create some examples based on this for C, Java, and Go as I know several HF users are coding with those:

Spoiler (Click to View)



I hope that this is helpful to you in some way for managing your network profiles and possibly automating this in your scripts as well. Ask questions or share knowledge below :)
I know this isn't the case but could you imagine the PHP executing that on the website visitor and killing someone's internet when they load the page. That'd be hilarious
(Jan 9, 2024 05:17 PM)Lor‌d Wrote:  I know this isn't the case but could you imagine the PHP executing that on the website visitor and killing someone's internet when they load the page. That'd be hilarious

It would be cool to see a PHP client-side language, but at the end of the day it would have to be a wrapper for JS or a custom extension, or whole new web browser or major companies would have to support PHP(client) - like within Chrome, Safari, Firefox, Edge, etc.

I would like to see that one day though. It would be a cool way for PHP devs to easily move to the frontend and use familiar functions & syntax, similar to how JS devs were able to move to backend with Node.js, Next, and similar frameworks/stacks.
(Jan 9, 2024 07:59 PM)Hackers Wrote:  It would be cool to see a PHP client-side language, but at the end of the day it would have to be a wrapper for JS or a custom extension, or whole new web browser or major companies would have to support PHP(client) - like within Chrome, Safari, Firefox, Edge, etc.

I would like to see that one day though. It would be a cool way for PHP devs to easily move to the frontend and use familiar functions & syntax, similar to how JS devs were able to move to backend with Node.js, Next, and similar frameworks/stacks.

I agree but I've also found learning JS with having a bit of a background in PHP wasn't too terrible.
I don't see any major companies jumping at the chance to have client sided PHP any time soon
(Jan 9, 2024 08:06 PM)Lor‌d Wrote:  I agree but I've also found learning JS with having a bit of a background in PHP wasn't too terrible.
I don't see any major companies jumping at the chance to have client sided PHP any time soon

Hahaha very true - it would be more helpful for the devs out there than the clients & customers. Typescript is exciting enough anyways to spice up the life of JS devs.
I'm Stanley HF's helper bot. The OP (original poster) of this thread wants everyone to see this page and has elected to bump it to the top of the showthread listing. Since HF doesn't want a ton of LQP (Low Quality Posts) this is the best method of bumping your content. There is a small βyte fee for each bump. Any OP can bump any of their threads on HF from the linked icon on the top of their first post.

If you haven't already read the first post of this thread we encourage you to do so.

Thanks,
Stanley
I am the official HF Help Bot.  You might get an automated PM from me with some helpful information.
Please read our Help Docs.
I still think this is useful to people :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Murphys_lawlessFeb 9, 2014 06:50 AM 12 767 Feb 9, 2014 06:50 AM
Last Post: chieffinj3ct0r
by LevelUpMar 29, 2013 04:12 PM 16 1,079 Mar 29, 2013 04:12 PM
Last Post: RazerGuy
by TheNeutronJan 24, 2012 07:48 AM 9 346 Jan 24, 2012 07:48 AM
Last Post: roxxor1339