From 88d9e2972a112b2ce1859f286bc3b19b8a8fe139 Mon Sep 17 00:00:00 2001 From: jazir5 <31750063+jazir555@users.noreply.github.com> Date: Wed, 5 Mar 2025 22:25:03 -0800 Subject: [PATCH] Update Enable GamesDows Playnite.bat --- Enable GamesDows Playnite.bat | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Enable GamesDows Playnite.bat b/Enable GamesDows Playnite.bat index 0696964..81a9a16 100644 --- a/Enable GamesDows Playnite.bat +++ b/Enable GamesDows Playnite.bat @@ -1,17 +1,27 @@ @echo off -SETLOCAL EnableExtensions -@echo off -echo Checking for administrative privileges -net session >nul 2>&1 -if %errorlevel% neq 0 ( - echo ==================================================== - echo This script must be run with administrative privileges. - echo Please right-click on the script and select "Run as administrator." - echo ==================================================== - pause - exit /b +:: Self-elevating Admin script +:: This script will automatically request admin rights if not running as admin + +:: Check for admin rights and self-elevate if needed +>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" +if '%errorlevel%' NEQ '0' ( + echo Requesting administrative privileges... + goto UACPrompt +) else ( + goto GotAdmin ) +:UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" + "%temp%\getadmin.vbs" + exit /B + +:GotAdmin + if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" + pushd "%CD%" + CD /D "%~dp0" + echo Setting Playnite as default shell echo Set Playnite as the default shell