views:

695

answers:

5

I'm having a problem with good ol' bdeadmin.exe in Vista. First, let's get the predictable responses out of the way:

"You should not require your application to be elevated."
This one does. C'est la vie.

"You need to embed a manifest file."
It is already compiled, it is many years old, the company that created it has no intention of doing it again, and it is installed from a Merge Module (MSM file).

"BDE is obsolete, you should be using dbExpress"
One and a half million lines of code. 'Nuff said.

"Drop a manifest file next to the EXE."
Tried that, did nothing. As a test, that same manifest file was able to make several other EXE files require elevation, just not the one I wanted. Something in there is preventing the external manifest from being read.

"Create a shortcut and set SLDF_RUNAS_USER."
Can't do that, it's a Control Panel applet.

The only thing that worked was setting "Run this program as an administrator" under the Compatibility tab of its Properties window. I shouldn't have to tell users to do this. Bad for business. I need to have the installer do this. The MSM file uses a static path.

Any ideas?

A: 

I'd be surprised if this was possible. It would be an ideal way for malicious code to abuse the system. You're probably going to have tell the user the administrator must install or they must have admin rights (like all the other programs on windows do).

Jay
It doesn't appear like you took the time to understand the question. He is trying to get his application to run as an administrator with a user that has admin rights on a machine has UAC enabled. In its current state, his app doesn't prompt for elevation and runs without admin rights, and fails. He is trying to get it to prompt for elevation, not bypass Windows' security.
Allon Guralnek
+1  A: 

Have you tried Microsoft's Application Compatibility Toolkit? It analyses your app and provides compatibility shims that might be able to help resolve your problem.

Aaron Klotz
Interesting. I may be able to merge the contents of their generated MSI with my own installer.
Patrick
Nope, didn't work. Close, though.
Patrick
A: 

This is a long shot, but if you have the word "setup" or "install" in the name of the EXE, Windows will prompt for elevation when running it. I don't know if that'll work with a control panel applet, though.

Allon Guralnek
+2  A: 

You can programmatically set the "Run this program as an administrator" flag (the option you find in the Compatibility tab of an EXE's properties), by setting a simple registry key. You need to create a string value (REG_SZ) under one of these keys (if you want the setting to be per user or per machine, respectively):

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

The name of the value needs to be the full path to your executable (if the path contains spaces, do not surround the path with quotes) and the data of the value must contain the string RUNASADMIN.

Allon Guralnek
This looks promising. Now to get that into [COMMONFILESFOLDER] in an msi
Patrick
The only sticky bit is using the MSI variable in the registry value name. That is showing up blank. But you answered my question, thank you. I'm going to use %commonprogramfiles% and %commonprogramfiles(x86)% in two different values until that part is solved.
Patrick
You might want to open up a separate question for your MSI conundrum. I know from my dealings with MSI that I'm pretty clueless about it, especially since I find its documentation to be rather lackluster. When I hit a wall, I usually just throw whatever I need to do into a custom action (which is ridiculously easy to do, at least with .NET).
Allon Guralnek
A: 

Use a wrap program which uses ShellExcute that uses "runas" as its "verb" to run the program you want.