Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:52:22+00:00 2026-05-22T19:52:22+00:00

Some applications, started with a regular user will ask for elevated permissions when necessary

  • 0

Some applications, started with a regular user will ask for elevated permissions when necessary (e.g. a file manager needs to write such folder), and then carry on with the operation.

How can I replicate this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:52:23+00:00Added an answer on May 22, 2026 at 7:52 pm

    As Tamás pointed out you need to launch a new process with elevated rights. I searched a lot in the past but I did not find any way to elevate the rights of the current process.

    Lets say your primary app is App1.exe and then you call a secondary process App2.exe which requires elevated rights.


    A. You can embed a manifest in your App2.exe but the simpler way is to create a manifest file [a text file] named App2.exe.manifest with the following contents and put it in the same directory as App2.exe.
    Note: !! Strangely enough, if the name of your application is not App2.exe but App2_install.exe or App2_setup.exe (i.e. if the application name contains the “install” or “setup”) an UAC Dialog will appear automatically in Windows Vista / Windows 7 and will ask for elevated rights even there is no manifest file !!
    This is a sample of the manifest file:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
    <requestedPrivileges>
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
    </requestedPrivileges>
    </security>
    </trustInfo>
    </assembly>
    

    B. You can use a code like the following in App1.exe to launch the App2.exe

    QString AppToExec = qApp->applicationDirPath() + "/App2.exe";
    // Put any required parameters of App2.exe to AppParams string
    QString AppParams = "";
    if (0 != genWin32ShellExecute(AppToExec, 
                                  "",    // default verb: "open" or "exec"
                                  AppParams,
                                  false, // run hidden
                                  true)) // wait to finish
    {
        // (...) handle error
    }
    

    …and finally, this is the code of the Win32 function genWin32ShellExecute() I created to launch a process or open a document when using QT on a Win32 O/S:

    Header:

    #ifdef Q_OS_WIN  // Implement genWin32ShellExecute() especially for UAC
        #include "qt_windows.h"
        #include "qwindowdefs_win.h"
        #include <shellapi.h>
    
    int genWin32ShellExecute(QString AppFullPath,
                             QString Verb,
                             QString Params,
                             bool ShowAppWindow,
                             bool WaitToFinish);
    #endif
    

    CPP:

    // Execute/Open the specified Application/Document with the given command
    // line Parameters
    // (if WaitToFinish == true, wait for the spawn process to finish)
    //
    // Verb parameter values:
    // ""           The degault verb for the associated AppFullPath
    // "edit"       Launches an editor and opens the document for editing.
    // "find"       Initiates a search starting from the specified directory.
    // "open"       Launches an application. If this file is not an executable file, its associated application is launched.
    // "print"      Prints the document file.
    // "properties" Displays the object's properties.
    //
    // Ret: 0 = success
    //     <0 = error
    #ifdef Q_OS_WIN
    int genWin32ShellExecute(QString AppFullPath,
                             QString Verb,
                             QString Params,
                             bool ShowAppWindow,
                             bool WaitToFinish)
    {
        int Result = 0;
    
        // Setup the required structure
        SHELLEXECUTEINFO ShExecInfo;
        memset(&ShExecInfo, 0, sizeof(SHELLEXECUTEINFO));
        ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
        ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
        ShExecInfo.hwnd = NULL;
        ShExecInfo.lpVerb = NULL;
        if (Verb.length() > 0)
            ShExecInfo.lpVerb = reinterpret_cast<const WCHAR *>(Verb.utf16());
        ShExecInfo.lpFile = NULL;
        if (AppFullPath.length() > 0)
            ShExecInfo.lpFile = reinterpret_cast<const WCHAR *>(AppFullPath.utf16());
        ShExecInfo.lpParameters = NULL;
        if (Params.length() > 0)
            ShExecInfo.lpParameters = reinterpret_cast<const WCHAR *>(Params.utf16());
        ShExecInfo.lpDirectory = NULL;
        ShExecInfo.nShow = (ShowAppWindow ? SW_SHOW : SW_HIDE);
        ShExecInfo.hInstApp = NULL;
    
        // Spawn the process
        if (ShellExecuteEx(&ShExecInfo) == FALSE)
        {
            Result = -1; // Failed to execute process
        } else if (WaitToFinish)
        {
            WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
        }
    
        return Result;
    }
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, I started changing some of our applications to support MS SQL Server as
I am using Windows, and I have two monitors. Some applications will always start
I've recently started upgrading some applications to use Spring Webflow 2, and I want
Some applications (or websites) compute a password's complexity as you type. They typically display
In some applications (notably Visual Studio 2008, Windows Explorer, Internet Explorer) all of the
I've written some applications than heavily use network, and I would like to test
I have some applications (some native, some .NET) which use manifest files so that
I'm getting some weird behaviour recompiling some applications in 2009 that used widestrings at
I have this kind of code in some applications (from microsoft) [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( Microsoft.Naming,
I currently use my local web server to allow costumers to preview some applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.