Forcing my application to run with administrative privileges

  • Thread starter Thread starter Sarah M. Weinberger
  • Start date Start date
S

Sarah M. Weinberger

Hi,

I have a VB6 based application and I read a post that I should post an entry
here, so I am doing so. My application needs to run with administrative
privileges. As a VB6 appliction it is not a .Net application that has built
in support for manifests. Visual Basic v6.0 does not support direct
manifests, but I am using InstallShield, which is running with
administrative privileges. The question is what changes do I need to make to
cause my application to forcibly run in administrative mode? Another post
mentioned that all the manifest does is to make an entry to the

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentViersion\AppCompatFlags\Layers

hive/folder. I checked this path on my Windows Vista installation and I do
not see the Layers sub-folder. Sadly, the post does not mention what the
settings are. I figured as much that all the manifest does is to set a
registry entry in the registry, which tells Windows that whenever and
however the application runs, be it by shortcut or direct launch, that the
privilege level should be as an administrator.

What are the settings that I should make to the registry to affect my VB6
application to run as with administrator privileges?

Is there another method?

Thanks in advance,

Sarah M. Weinberger
ButterflyVista, LLC
 
Hello,

A manifest is an XML file that is embedded into your application, in the
same way that your application's icon file is embedded into it.

When your application is executed, Windows loads the manifest and uses it to
determine how to start your application.

It does not change/modify the registry.

Applications should not rely on the application compatability layer to mark
their application as requiring elevation. All applications that are designed
to run on Vista should include a manifest (whether they need to elevate or
not) :)

You have two options: You can either embed the manifest into your
application, or you can create a manifest file named
yourapplication.exe.manifest (where yourapplication.exe is the filename of
your application) and install it to the same location that your application
..exe is installed to.

Obviosuly, the best way when distributing your application is to embed it
into your .exe.

To do that, you need a free tool called mt.exe (available from the Windows
SDK).

The command line looks like this (Note the ;#1 at the end is important):

mt.exe -manifest "path_to_manifest" –outputresource:"path_to_exe";#1
 
Hi Jimmy and Brink,

I was finally able to embed a manifest thanks to the prolonged help of
someone in another newsgroup. I do got to comment that the manifest has to
be just right and that finding out how to add the manifest to an existing
resource (using VC++, as that has a nice resource editor) was not all that
obvious, but once done it works. My only complaint to Microsoft is that the
message that UAC pops up should be a bit more clear. It is not obvious that
the application requests to run in elevated / administrative mode, even
though that is what the confirmation screen asks.

Sarah
 
Back
Top