0

I read some topics here, but I haven't found the solution of my problem. I wrote application(C#, WPF, EF, sql server compact) that should start at windows startup. I tried to achieve that in two ways:

  1. Add entry to windows register. Unfortunately that wasn't work on Windows 7. I found here that adding a shortcut to Startup folder can solve my problem...
  2. I've added shortcut to my application in Startup folder. Unfortunately again it is not working...

My application is starting with admin permissions because is using external dll's sql server compact. Maybe this is reason? In addition my application is not signed and probably will not be. Also writing a wcf service could be bad idea in my application.

Do you have any suggestions, or solutions for that problem?

nosbor
  • 2,826
  • 3
  • 39
  • 63
  • What does the application do? Maybe start it as a Windows Service? If it needs a UI, can the UI component and the auto-startup background component be separated? – David Mar 26 '12 at 19:48
  • 2
    Have you tried using the task scheduler? http://www.sevenforums.com/tutorials/67503-task-create-run-program-startup-log.html – Tudor Mar 26 '12 at 19:50
  • It's simple application which user can want start at windows startup or not. For example, not everyone want to start utorrent at windows startup(all the more as a service). You can imagine that my application has similar features. – nosbor Mar 26 '12 at 19:51
  • Do you have error messages? Simply saying 'it is not working' can't help us to help you. – Steve Mar 26 '12 at 19:53
  • Have you tried using the windows Task Scheduler to run the application as soon as windows starts? – Robbie Mar 26 '12 at 19:50
  • No I haven't.. How can I do it in .net? Do you have any simple exaples? – nosbor Mar 26 '12 at 20:04

2 Answers2

2

It's against windows guidelines ( and enforced by the operating system ) to put a program that requires UAC elevation in the startup process. It's a horrible user experience to be prompted for elevation every time they logon to a computer.

I would factor the wcf / sql into a service and keep the client side UI elevation free.

Reference: Error message when you start a Windows Vista-based computer: "Windows has blocked some startup programs"

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Your link explains how to do it manualy. Can you give me some advice how can I make it in c#? I need three operations: check if application is set to start on windows startup, add application to startup and remove application from startup. I don't wanna use COM. Only .net. – nosbor Mar 26 '12 at 19:57
  • You don't do it. You refactor your application so that it doesn't require admin to run. – Christopher Painter Mar 26 '12 at 19:58
0

The solution for that problem was to make user to install sql server compact on his own computer instead of embeding it in application folder and change permissions for application to asInvoker from admin.

nosbor
  • 2,826
  • 3
  • 39
  • 63