PDA

View Full Version : Application Signing



kiboi
11th October 2012, 09:03
How to run the exe.file automatically running with administrative priviledges?

Added after 1 21 minutes:

Sorry, maybe I was not so clear.

I'm developing a software installable and I need some IO operations to detect devices(drives). I cannot detect without running as admin.

So I have some option to run my application with administrator privileges?

Thanks

ChrisW67
11th October 2012, 09:20
Assuming you mean Windows... then you want to set the


<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>

part of your application manifest to level="requireAdministrator"

kiboi
11th October 2012, 12:58
Thanks Chris. Where can we find the application manifest?

ChrisW67
11th October 2012, 23:33
A manifest is an XML file that is included in your program Windows resources.

If you are using the Microsoft tools then one is generated, placed in the release/debug folder with your program, and merged into your executable using the Microsoft MT.exe program. You can influence its content with linker switches, so the easiest way to achieve what you want is this in your PRO file:


win32-msvc* {
CONFIG += embed_manifest_exe
QMAKE_LFLAGS_WINDOWS += $$quote( /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" )
# Yes! All the backslashes and quotes are required!
}


If you are using MingW you have to provide the manifest XML file yourself, incorporate it in to your Windows RC file, and list that in the RC_FILES varaible in your PRO file.

kiboi
12th October 2012, 09:10
Thanks chris. this helps. Btw, is there a difference if i'll be using a mingw compiler?

wysota
12th October 2012, 09:21
Look at last sentence of Chris's post.

kiboi
12th October 2012, 09:34
sorry for that. i missed that line. thanks!

ChrisW67
13th October 2012, 05:05
A basic manifest looks like:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="kiboi.coolapp" type="win32" />
<description>Kiboi Cool Application</description>

<dependency />

<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

and it appears in your Windows resource (*.RC) file thus:


#include <windows.h>
ID_ICON ICON DISCARDABLE "coolapp.ico"
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "coolapp.exe.manifest"
...

and is incorporated through your PRO file thus:


...
RC_FILE = coolapp.rc
...

kiboi
20th October 2012, 03:34
hi chris,

I tried to add this on the PRO Files, cleaned and run qmake, when i open the application manifest,still the manifest level is "asInvoker". other than that, did i missed something?

Thanks!

ChrisW67
20th October 2012, 05:24
The manifest is written by you. Did you set the level to requireAdministrator or did you use the default one I gave you above?