Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easier installation #44

Open
Optiligence opened this issue Aug 31, 2019 · 1 comment
Open

easier installation #44

Optiligence opened this issue Aug 31, 2019 · 1 comment

Comments

@Optiligence
Copy link

From time to time i let users install Dr. Mingw and it’s a bit weird to tell them that they have to open an Admin command prompt, navigate to the extracted folder and execute some command to get it working.

Logic like this could imo be implemented as part of the usage prompt that comes up if you execute drmingw.exe in the explorer, but i currently simply share the following script which could be included as is without much further work needed:

REM http://stackoverflow.com/questions/1894967/how-to-request-administrator-access-inside-a-batch-file#10052222
@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------
"%CD%/bin/drmingw.exe" -i
@jrfonseca
Copy link
Owner

It would be better to avoid batch, and have drmingw to call itself again with elevator priviledges, and the same command line parameters, as exemplified in https://stackoverflow.com/a/6418873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants