Request administrator privileges (Win & Mac atleast)


Im building a web installer, and so far got it to work on mac using applescript, but on windows.. seems like a whole deal, is there any cross platform resource i could use to gain access on both platforms.. if not, could this be considered as a feature request?

thanks in advance


There has always been a Process::raisePrivilege() method, but I think it's only implemented on linux currently.


on Windows there is a linker option, UAC Execution Level "require Administrator".

Jules: This should be an option in Introjucer, if someone wants to create a setup application. (For example plugin-installer)



On Windows, you probably have to restart the process with admin rights. You can do it like this:


static bool elevateToAdminRights(String commandLineArgs)
    char szPath[MAX_PATH];
    if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)))
        // Re-launch ourselves with admin rights
        SHELLEXECUTEINFO sei = { sizeof(sei) };
        sei.lpVerb = "runas";
        sei.lpFile = szPath;
        sei.hwnd = NULL;
        sei.nShow = SW_NORMAL;
        sei.lpParameters = commandLineArgs.getCharPointer();
        if (!ShellExecuteEx(&sei))
            DWORD dwError = GetLastError();
            if (dwError == ERROR_CANCELLED)
                // User refused to allow privileges elevation.
                return false;
    return false;



hey thanks for the input !! myhrman i tried your code and it locks quite brutally, can you show how you are using it? thanks in advance man really appreciate


Nevermind guys !!! the linker preference thing on Visual Studio is way easier.. but it wil be rewritten every time i save the project with the introjucer !!! please help jules !!


Busy right now but if you could give me a mod for the introjucer, it's something I'd be happy to add!