I'm running a batch file to remove all personal WiFi networks from a Windows 10 device. We previously had an issue where WiFi profiles were being made under the SYSTEM account and it does not allow you to remove the profile. That has since been fixed, but previous networks saved under users computers need to be removed.
I have the following script to run and it's working as expected, BUT:
@ECHO OFF :: Checking for Admin (Right-click) Condition CLS NET SESSION > NUL IF NOT %ERRORLEVEL% EQU 0 ( COLOR 4F ECHO. ECHO ----- WARNING! ERROR EXECUTING THE COMMAND ----- ECHO. ECHO. ECHO You must right-click and select "Run as Administrator" from the pop-up menu ECHO. ECHO. GOTO END ) ELSE ( CLS ) setlocal :PROMPT ECHO Using this will delete ALL PERSONAL wifi networks. ECHO Users will have to type in their password for their specific SSID when in range. SET /P QUESTION=Are you sure? (Y/[N])? IF /I "%QUESTION%" NEQ "Y" GOTO END netsh wlan delete profile name=* ECHO Wifi networks deleted successfully :END echo. echo. PAUSE
We have 2 GPO assigned wireless networks. They are pushed through our wireless network policy. Looking for a possible EXCLUDE method to allow me to exclude those two from attempting to be deleted since I'm running a wildcard for ALL wireless profiles (Special cases where users would have access to delete those). Something like this possible?