c# - Granting administrator privileges to an application launched at startup without UAC prompt? -
background
i've written small c#/.net 4.0 application syncs various settings game installed in program files , other copies of same game on different machines (think chrome bookmark sync, game). sync relatively simple affair, dealing files stored inside game's program files folder.
on machine, works fine without having elevate application through uac. windows 7 makes game use program files virtualisation , application works fine that.
however, on lot of tester's machines, i'm getting reports application either can't work files , in come cases can't see game's folder! having user right-click , "run administrator" solves problem in every case.
so, set application's manifest require admin privileges, right? that's fine (although not ideal) when user manually invokes application or sync process because they'll interacting application , ready accept uac request.
however, 1 of features of application "sync automatically" option, allows user "set , forget" application. set, application puts registry @ hkcu\software\microsoft\windows\currentversion\run run @ startup , sits in system tray syncing settings in background needed.
obviously, need smarter here. presenting uac prompt user logs in account or @ random intervals afterwards isn't way forwards.
so, question!
what's best way approach situation i'd need run application @ startup needs administrator privileges? there way have user authorise installation causes system automatically run application correct privileges without prompt @ startup/login?
update clear, must achievable in code.
you should consider making sync functionality exist within windows service. preferred method running 'background' functionality on windows.
the service can either run under user's account (assuming have permissions modify files), or can use account does. worst case, can run system (although, isn't best practice).
if you've got background process functionality working, should simple process convert on service.
there's sample project here set on right path: http://www.codeproject.com/kb/dotnet/simplewindowsservice.aspx
Comments
Post a Comment