Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3357346
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:37:18+00:00 2026-05-18T02:37:18+00:00

I have a very old application that now needs to be friendly to Windows

  • 0

I have a very old application that now needs to be friendly to Windows Server 2008. It is a user application that works as singleton. It uses HKLM part of registry to read and write the configuration, and it creates log files.

Main question: how to make application work with UAC in regards to best current practice?

My initial approach is to run application non-elevated, and if configuration needs to be changed the user manually restarts it elevated, reconfigure, and restarts to non-elevated. The problem is that log file then can be created elevated as well, and then non-elevated application can not write to it. Possible workarounds:

  1. Don’t do anything in elevated mode that implies writing to log file. But how to detect if application is in elevated mode?
  2. Create log file with non-elevated privileges even in elevated mode. How?
  3. If access is denied when opening existing log file then try to create another log file.
  4. Run elevated all the time.

First option is best looking so far, but how to detect the elevation? Maybe there is some other option? Maybe there is some completely different approach? I’d like not to have to change the code too much if possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:37:19+00:00Added an answer on May 18, 2026 at 2:37 am

    The best practice is to rewrite the app to use per-user storage unless you really need something saved by one user to affect other users on the box. That is, the answer “there is only one user, so per-user and per-machine are the same” is rejected. In this case the whole app always runs non-elevated, with a manifest to prevent virtualization.

    The next best practice is to partition the application. The code that writes to HKLM is in a separate exe, and has a manifest requesting elevation. The UI has some warning (a shield on a button or menu item) where the user makes this code run. The separate process is launched with ShellExecute, which respects manifests. The experience for the user is that most of the time the app runs non elevated, and sometimes parts of it appear to elevate and then come down. That’s what it seems like but that’s actually impossible – an exe is either elevated or not. You achieve the effect with two exes.

    The third best thing is to move the log somewhere that is the same whether you are elevated or not, and train your users to hand-elevate when required. I don’t think it’s a good solution at all, but it’s better than training them to hand-elevate and writing the log file in a different place every time. I’m guessing you write under “the current directory”, which is itself under Program Files, and that you have no manifest. Then when not elevated your app will write under the virtual store. If users need to look for log files this is really not good. Write to a different folder – something under AppData would be good. That location will not be virtualized.

    The simplest way to detect if you are elevated is to use IsInRole to see if the user is an admin. As a little testing will prove, even admin users get false returned when the app is not elevated, and even non admins who elevated with OTS prompt will get true returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old Classic ASP application. Now the users wants to have some
I'm trying to move a classing ASP site to a 64-bit Windows 2008 server.
I have a Delphi application that reads/writes to a COM port connected to a
I have an open API in my application that I'd like to provide access
Back in the old days, text-to-speech, as cutting edge as it was, was very
I am working on a Spring MVC application in which I have recently been
I am working on a web application where images has to be scaled dynamically
I am trying to build the very lightweight solution for zero downtime deployment for
In my developments I am slowly moving from an object-oriented approach to interface-based-programming approach.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.