Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active November 16, 2022 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tresf/42ddd8d4a1fac96adccf3d8b5864d051 to your computer and use it in GitHub Desktop.
Save tresf/42ddd8d4a1fac96adccf3d8b5864d051 to your computer and use it in GitHub Desktop.
Add entry to properties file
@echo off
NET SESSION >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo Administrator PRIVILEGES Detected!
) else (
echo NOT AN ADMIN!
pause
exit
)
REM (e.g. file.whitelist=C\:\\User\\Roaming\\AppData\\CustomDir\\)
set prop=file.whitelist
set data=%APPDATA%\CustomDir\;
type "%PROGRAMFILES%\QZ Tray\qz-tray.properties" |find "%prop%" >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo.
echo Entry file.whitelist already exists, skipping
echo.
goto show_properties
) else (
echo.
echo Entry file.whitelist not found, we'll add it
echo.
)
REM Escape special characters
set value=%value:\=\\%
set value=%value::=\:%
echo file.whitelist=%value%>> "%PROGRAMFILES%\QZ Tray\qz-tray.properties"
echo.
echo Successfully wrote %value% to qz-tray.properties
echo.
:show_properties
type "%PROGRAMFILES%\QZ Tray\qz-tray.properties"
echo.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment