c# - Elevating process privilege programmatically? -


i'm trying install service using installutil.exe invoked through process.start. here's code:

processstartinfo startinfo = new processstartinfo (m_strinstallutil, strexepath); system.diagnostics.process.start (startinfo); 

where m_strinstallutil qualified path , exe "installutil.exe" , strexepath qualified path/name service.

running command line syntax elevated command prompt works; running app (using above code) not. assume i'm dealing process elevation issue, how run process in elevated state? need @ shellexecute this?

this on windows vista. running process in vs2008 debugger elevated admin privilege.

i tried setting startinfo.verb = "runas"; didn't seem solve problem.

you can indicate new process should started elevated permissions setting verb property of startinfo object 'runas', follows:

startinfo.verb = "runas"; 

this cause windows behave if process has been started explorer "run administrator" menu command.

this mean uac prompt come , need acknowledged user: if undesirable (for example because happen in middle of lengthy process), you'll need run entire host process elevated permissions create , embed application manifest (uac) require 'highestavailable' execution level: cause uac prompt appear app started, , cause child processes run elevated permissions without additional prompting.

edit: see edited question state "runas" didn't work you. that's strange, should (and me in several production apps). requiring parent process run elevated rights embedding manifest should work, though.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -