1

Ok i am working on an application which is basically an activity monitor.

This application will automatically log out a user if there is no activity for some time. I have successfully done the logout part.

But i am trying to automatically start the application when another or same user logged in again.

I tried startup code but it only works when windows starts up.

 private void SetStartup()
        {
            RegistryKey rk = Registry.CurrentUser.OpenSubKey
                ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

                rk.SetValue("My_App", Application.ExecutablePath);

        }

So is there any way to know when someone login in the system. I am using winform and c#. Let me know if someone needs more information Thanks.

Uniquedesign
  • 423
  • 1
  • 7
  • 23
  • Check [https://stackoverflow.com/questions/40423190/detect-windows-logon-attempts-programmatically-using-c-sharp](https://stackoverflow.com/questions/40423190/detect-windows-logon-attempts-programmatically-using-c-sharp) – mahlatse Nov 22 '18 at 16:47

1 Answers1

2

You can place a shortcut to your application in the "Startup" folder for all users. The location of this depends on your operating system.

Windows 10: press windows key+R, then type "shell:common startup". Put a shortcut to your application in here.

On Windows 7 it was at "C:\Documents and Settings\All Users\Start Menu\Programs\Startup".

If it's neither of those, add a comment...

Each time someone logs on, the application will be run.

Richardissimo
  • 5,596
  • 2
  • 18
  • 36
  • Thanks for sharing this information, but i was looking for something, more logical through coding. but anyways, thanks it is also a good solution. – Uniquedesign Nov 24 '18 at 11:18