Open
Description
System: Windows 10 22H2
Processor: AMD
Local User
silent_install.bat isn't getting admin privledges on my system. I've installed through Android Studio and an elevated cmd prompt. Rewrite silent_install.bat and problem is solved:
@echo off
:-------------------------------------
Check for admin rights
fltmc >nul 2>&1
if %errorlevel% NEQ 0 (
echo Requesting administrative privileges...
goto getAdmin
)
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
Parse commands
set action=install
:parseInput
if "%~1"=="" (
goto %action%
)
if /i "%~1"=="-u" (
set action=uninstall
shift
goto parseInput
)
if /i "%~1"=="-v" (
set action=checkinstall
shift
goto parseInput
)
REM Ignore other params
shift
goto parseInput
:getAdmin
>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 "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:install
sc query gvm >nul 2>&1
if %errorlevel% EQU 0 (
sc stop gvm
sc delete gvm
)
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 .\gvm.inf
if %errorlevel% NEQ 0 (
echo Failed to install GVM
exit /b 1
)
sc start gvm
exit /b 0
:uninstall
sc query gvm >nul 2>&1
if %errorlevel% NEQ 0 exit /b 0
sc stop gvm
sc delete gvm
if %errorlevel% NEQ 0 (
echo Failed to uninstall GVM
exit /b 1
)
exit /b 0
:checkinstall
sc query gvm >nul 2>&1
if %errorlevel% EQU 0 (
exit /b 0
) else (
exit /b 1
)
Metadata
Assignees
Labels
No labels