In WinForms application when my application is started then the User Account Control dialogbox comes(Only in Windows7).
Can anyone suggest me how programatically I can avoid this – That is my application should start always in admin mode or is there any option to stop this dialogbox from coming?
I am developing in C#,VS2008.
You cannot automatically start an application with higher privileges without accepting the prompt or telling Windows to always start that application with higher privileges. Being able to programatically change this behaviour would defeat the whole purpose of UAC. UAC comes up automatically if it’s active and an application does something that requires higher privileges than the current user. Being an administrator user does not give you the rights to do everything without confirmation first, which actually only then elevates your privileges if UAC is active.
What you should do is track down what actually triggers UAC in your application and remove that or modify it so that the application does not need higher privileges to successfully complete that task. You could also check if the manifest of your application requests higher privileges, check for requestedExecutionLevel in the manifest. In case you actually do need higher privileges your only way is to either tell the users to turn off UAC which still does not mean a “normal” user is able to run your application. Or to always accept the prompt when starting your application.