FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Manifest file to elevate User rights to Admin
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Manifest file to elevate User rights to Admin
Posted: Wed Sep 26, 2012 04:33 PM
To All

In many cases our programs need to have elevated privileges to run on Win7 to do certain tasks.. I searched that topic and came across this manifest file.


This works for me but it prompts for the user password.

Code:

cStrg := "runas /noprofile /user:" + GetEnv( "COMPUTERNAME" ) + "\" + GetEnv( "USERNAME" ) + " TELNET"
winexec( cStrg )


@Rick: when you use winexec waitrun etc... it seems you loose elevated privileges. My login has administrator privileges for my computer. If i open a prompt with start button I can run telnet. If I open the prompt with waitrun or winexec telnet does not appear even with dir c:\windows\system32.

_________________
André Dutheil
FWH 12.04 HB 3.1 BCC 5.82 MinGW 4.5.2 MSVS 10





I have not tested this in any application but if one of our friends would like to try here is the file and instructions from Microsoft. Like all manifests it would have to be added manually to a .rc and compiled into the application.

Let me know if anyone has success.

Rick Lipkin

Code (fw): Select all Collapse
Manifest File

To mark your application with a requestedExecutionLevel, first create an application manifest file to use with the target application. This file can be created by using any text editor. The application manifest file should have the same name as the target executable file with a .manifest extension. For example: IsUserAdmin.exe.manifest.
Example

Executable: IsUserAdmin.exe 
Manifest:IsUserAdmin.exe.manifest
Sample application manifest file:
<?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="IsUserAdmin"
     type="win32"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

The parts of the manifest that need to be adjusted for your application are marked in bold. They include the following:

    The assembly identity

    The name

    The type

    The description

    The attributes in the requestedExecutionLevel
Posts: 8
Joined: Sat Jan 19, 2008 03:38 PM
Re: Manifest file to elevate User rights to Admin
Posted: Tue Nov 06, 2012 12:33 PM
Hi Rick or who can.
Please, I´m trying it as you´ve mencioned but here I´m use Windows 8 and dont work.
You have some idea to my case, take a look in manifest:

Code (fw): Select all Collapse
<?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="FiveTech Software.FiveWin.32bits"
     type="win32"/>
  <description></description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="X86"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>


In TAG "assemblyIdentity" I already test with my application name, but also nothing...

Code (fw): Select all Collapse
 <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="Menu.EXE"
     type="win32"/>


And in my .RC is..

Code (fw): Select all Collapse
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

HAND CURSOR "res1.cur"

MMENUICO ICON "MENU.ICO"

MENU.EXE.MANIFEST MANIFEST "Menu.exe.manifest"


Thanks!!!

Continue the discussion