How to Run VB6 EXE as administrator programatically?

319 Views Asked by At

I have an old application developed in VB6, now I have some add-on (DLL as component) in C# attached to it, which required administrator privileges to write registry in 64 bit systems (windows 8).

If I run my application by right clicking "Run as administrator" program works fine and DLL writes to the registry but if I run it as a normal user registry write fails.

I know if I add registry values in HKLM...AppCompatFlags->Layers it will work but how to add that value programatically or during setup (made using WISE 9)?

1

There are 1 best solutions below

0
On BEST ANSWER

You would normally apply appcompat at installation by installing an appcompat database. See the Application Compatibility Toolkit or the current version if a new one has been posted. Also see Deploying Application Compatibility Databases for Windows 7.

However a far simpler solution is to just embed an application manifest in your program that requests elevation.

If you're unaware of this and how to accomplish it you must have been sleeping since 2006, however a search of web sites such as MSDN Blogs ought to turn up some answers. For cookbook VB6 approaches you might search popular VB6 forum and blog sites, which tend to have a far more friendly format than StackOverflow for tutorials and examples.