Featured Posts

Using IssProc with NSIS to detect files in use Although IssProc was specially designed for Inno Setup scripts, you can also use it with other setup scripts like NSIS (Nullsoft Scriptable Install System) :) Here is a few steps you need to do in...

Readmore

Using IssProc with NSIS to detect files in use Although IssProc was specially designed for Inno Setup scripts, you can also use it with other setup scripts like NSIS (Nullsoft Scriptable Install System) Here is a few steps you need to do in order...

Readmore

IssProc (DLL Component) Launched IssProc is a user friendly "file in use" extension for Inno Setup (or other setup builder application like NSIS) that can be used to detect if a certain application (exe, dll module, ocx and so on) or...

Readmore

HDDPhysic v1.1.0 is released! Today we've released a new updated version of HDDPhysic (v1.1.0) Here is what’s new in this version: improved hardware serial extraction in Vista and W blog book guest levitra ru siteindows...

Readmore

Promote software on your website and get paid for it!... Join our affiliates network and get 25% commission on every sale you refer! Become a rlByte Software affiliate today!   To start selling, all you need to do is display product information...

Readmore

  • Prev
  • Next

USBPhysic and Win Vista / 7 UAC (workaround)

Posted on : 29-01-2010 | By : rlByte Team | In : USBPhysic

0

This workaround is not required anymore,

starting from version 1.1.0 of USBPhysic you don’t need to have your application elevated in Windows Vista or 7, no admin rights required anymore.

Now it works even with a guest account type.

Issue:

 Using USBPhysic to query hard drive physical data may fail sometimes on Vista / Windows 7 if UAC (User Account Control) is enabled and calling application is not launched with sufficient rights.

Workaround

 To work around this issue without forcing the user to disable UAC mark your application with a requestedExecutionLevel. To do that you must create and embed an application manifest with your application that tells the operating system what the application needs ( digital signing of the EXE is also a good idea).
This is the format:

<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>

 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: MyApp.exe
Manifest: MyApp.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="application name" type="win32"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
         <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator"/>
         </requestedPrivileges>
      </security>
   </trustInfo>
</assembly>

Next, you have to attach the application manifest to the executable by adding a line in the resource file of the application (the .rc file) to have Microsoft Visual Studio embed your manifest within the resource section of the PE file. To accomplish this, place the application manifest in the same directory as the source code for the project you are building and edit the resource file to include the following lines:

#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "MyApp.exe.manifest"

  After rebuilding the application, the application manifest should be embedded in the resource section of the executable.

Check your exe file with a resource viewer, you should see something like this: