Question

Is there a way to detect what prevents an app from running in a non-elevated state? When we run our application with elevated permissions it operates without any problems. Running in a non-elevated state prevents the application from starting.

Are there any tricks to detecting what might be preventing the app from running non-elevated?

Our application does not write data to a protected folder, i.e. program files.

Était-ce utile?

La solution

You can view the exceptions it threw in Windows Event Viewer (not the most efficient method) or wrap the whole program with an exception handler that displays or logs the exception info (a better approach if you have the luxury of being able to edit and build the project). Once you have the exception it shouldn't be too much trouble finding the operations where you have insufficient privileges.

Autres conseils

You should log errors to a file (or to the console, or whatever you like) to see which instruction is causing the problem. You could also detect the error in debug, but for this VS must not be running as admin.

Anyway, the most common cause is that you're trying to write to a directory which is writable only with elevated privileges (e.g. Program Files, Windows...), or a registry key in any hive other than HKEY_CURRENT_USER.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top