Question

Small parts of my application require admin rights (activation of the software needs to go to HKLM). For this, I draw shield icons on the buttons whose action require admin rights and when clicking, I restart the application with an appropriate parameter again using "runas" verb.

This works very good! However, now it happens that users execute the application from a network share. If they click on the "admin rights button" now, they get an error message because the network drive is not mapped for the administrator, therefore the executeable can't be found :-(

What's the best way around this?

Was it helpful?

Solution

Mapped drives are stored with each logon session, so you don't have them after elevation.

You can extract the admin interface to another executable and mark it as requireAdministrator in the manifested. Then launch the admin executable via ShellExecute. Windows Explorer will copy the drive mapping in this case (undocumented behavior, though).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top