C # install project output automatically starts with administrative rights

I created a setup project for a .net app that works great. The problem is that the application starts writing log files after launch and it requires administrator rights on Vista and Windows 7. I know there are some folders I could use to write without administrative rights. When I run the application as administrator everything works fine.

I asked myself if it is possible to modify the installation project in visual studio so that the installed application automatically has administrator rights on the target system?

Thanks for any help in advance!

Alex

+2


a source to share


3 answers


You don't want to do this. If it needs permissions on a specific directory, create an account that has them (or change the permissions on a subdirectory so everyone can access it). But don't run as admin for just one function. Also, investigate if there is another directory that you could write that you already have rights to.



+4


a source


To answer your direct question, yes, you can set up a startup condition for a setup project that requires an administrator, I believe this will take care of proper escalation for you.

here's a thread with detailed instructions.



Now to expand, I agree with Stephen that you MUST NOT do this, at least not just to write a log file .....

0


a source


You can technically do this with a bad hack: the idea is for the installer that is doing the elevated work to create a scheduled task that runs the program as admin.

Rather than directly creating a shortcut for your application, the installation creates a shortcut for this scheduled task.

See this as a link on how to do it manually: http://www.howtogeek.com/howto/windows-vista/create-administrator-mode-shortcuts-without-uac-prompts-in-windows-vista/

You just need to find a way to create the task programmatically from your setup.

On the other hand, I totally agree with Stephen. Try to do it the "right" way and don't fool Windows security. This is good, and working around it makes the system potentially insecure, and you don't want to be the one who compromises the security of other computers.

0


a source







All Articles