The script no longer requires admin rights

If it is running with admin rights,
it will add the Wi-Fi profile for all users.
This commit is contained in:
Pavel Valach 2020-12-04 23:16:55 +01:00
parent 80b52c5cfe
commit e194e54c32
No known key found for this signature in database
GPG key ID: 5B4C9E8526682172

View file

@ -1,27 +1,22 @@
@echo off
set mypath=%~dp0
set rights_admin=0
:: Check admin rights
NET SESSION >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
echo ######## ######## ######## ####### ########
echo ## ## ## ## ## ## ## ## ##
echo ## ## ## ## ## ## ## ## ##
echo ###### ######## ######## ## ## ########
echo ## ## ## ## ## ## ## ## ##
echo ## ## ## ## ## ## ## ## ##
echo ######## ## ## ## ## ####### ## ##
echo ####### Running as a regular user #########
echo # The Wi-Fi profiles will be installed #
echo # for the current user. #
echo # Run as administrator to install them #
echo # for all users. #
echo ###########################################
echo.
echo.
echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########
echo This script must be run as administrator to work properly!
echo If you're seeing this after clicking on a start menu icon, then right click on the shortcut and select "Run As Administrator".
echo ##########################################################
echo.
PAUSE
EXIT /B 1
pause
) ELSE (
set rights_admin=1
)
@ -56,8 +51,12 @@ goto main
:setup_wifi
cls
netsh wlan add profile "filename=%mypath%Wi-Fi-Sincoolka.xml"
netsh wlan add profile "filename=%mypath%Wi-Fi-Sincoolka 5G.xml"
set cmd_user=current
IF %rights_admin% EQU 1 (
set cmd_user=all
)
netsh wlan add profile "filename=%mypath%Wi-Fi-Sincoolka.xml" user=%cmd_user%
netsh wlan add profile "filename=%mypath%Wi-Fi-Sincoolka 5G.xml" user=%cmd_user%
echo.