Last active
August 7, 2022 13:52
-
-
Save linusgke/dd20e8eb9655e4485087d5ec3f093b7e to your computer and use it in GitHub Desktop.
Windows script enabling Windows Management Instrumentation (WMI)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Windows script enabling Windows Management Instrumentation (WMI) | |
:: https://gist.github.com/elektr0nisch/dd20e8eb9655e4485087d5ec3f093b7e | |
:: Attention! Firewall rules have to be adressed by their display name. | |
:: Therefore this script is language dependent and only supports english and german at the moment. | |
@echo off | |
:: Checking administrator privilges | |
net session >nul 2>&1 | |
if %errorLevel% neq 0 ( | |
echo This script must be run as an administrator. | |
goto END | |
) | |
:: Add registry key "LocalAccountTokenFilterPolicy" | |
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f >nul | |
:: Determination of system language | |
for /F "tokens=2 delims==" %%l in ('wmic os get OSLanguage /Value') do set LANG=%%l | |
if %LANG% == 1031 goto GERMAN | |
else goto ENGLISH | |
:: Allow WMI through firewall | |
:GERMAN | |
netsh advfirewall firewall set rule group="Windows-Verwaltungsinstrumentation (WMI)" new enable=yes >nul | |
goto END | |
:ENGLISH | |
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes >nul | |
goto END | |
:END | |
echo Done. | |
pause | |
exit /b 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment