Search code examples
c#.netwindows-7registryautostart

Start program at windows 7 startup(Autostart)


I've wrote a application which should starts at windows startup. I've add a entry in windows register in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. Entry has been added successfully, but program is not starting properly.

I've tested application on Windows 7 64 bits. Application needs to have admin permissions to run, maybe this is the reason why it is not starting?

I saw also that the entry's value is not in the quotation marks, but the others are. Is it compulsory?

Here is my c# code:

            var registry = Registry.CurrentUser;
            var key = registry.OpenSubKey(runKeyBase, true);
            key.SetValue(KEY, directory + @"\" + filename);
            Registry.CurrentUser.Flush();

How cant I make it working?


Solution

  • As far as I see this is due to user access control settings that allows only signed applications to start else it will ask for Administrator permissions.

    Due to this during startup, OS will simply not run the application even if you have done registry settings.

    Also quotation are not mandatory. You can either have them or not.

    The way I did was to place a shortcut in the Startup folder. Registry settings will not work.

    Additionally One thing you can try is place the file in /system32 or /windows and then try setting in registry.