How do I make the windows application run automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    How do I make the windows application run automatically

    Hi All,

    I have a Windows application that should run 24*7, I scheduled the task and gave run when system starts, neither did it pop the windows screen, or did it run. I could not see the windows application in the Process panel of the Task Manager.
    But later I deleted the scheduled task and gave Run and specified the timings too.
    The application ran successfully.

    Where am I going wrong?. Apart from scheduling a task is there any other way of running an windows application automatically without manual intervention (excluding windows service)

    Thnx in advance.

    Regards
    cmrhema
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    As yours is a windows application you can use the following code to put your application to run on start up....

    Code:
    public static void SetAtStartUp()
            {
                RegistryKey startUpKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                try
                {
    
                    if (startUpKey.GetValue("YourKeyName") == null)
                    {
                        startUpKey.SetValue("YourKeyName", Convert.ToString(Application.ExecutablePath));
                    }
    
                    else
                    {
                        object o = startUpKey.GetValue("YourKeyName");
    
                        if (o.ToString() != Convert.ToString(Application.ExecutablePath))
                        {
                            startUpKey.SetValue("YourKeyName", Convert.ToString(Application.ExecutablePath));
                        }
                    }
                }
    
                catch (Exception ex)
                {
                }
            }
    You can look into windows service( converting your windows application functionality into a windows service) as long as there is no GUI interaction needed....

    Comment

    • kunal pawar
      Contributor
      • Oct 2007
      • 297

      #3
      Or you can write Windows service which give the call to your application.

      Comment

      • PRR
        Recognized Expert Contributor
        • Dec 2007
        • 750

        #4
        Originally posted by kunal pawar
        Or you can write Windows service which give the call to your application.
        If you call a program from windows service, the "program" runs in the context service account (system,local or network)... This may have its own implications... Obviously the "program" wont be visible to the current active user... however it will be visible on task manager or if you loop through like
        Code:
        System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcesses();
        you will find it ....
        So the "program" wont be visible in GUI.... Try opening a notepad from service or taking a system snap... you will get the picture ....

        Comment

        • cmrhema
          Contributor
          • Jan 2007
          • 375

          #5
          Thank you Deep Blue for your valuable suggestions.
          We tried a "lazy" method. Created a shortcut and placed in the Windows Startup menu folder.

          Once again thanks

          Comment

          • PRR
            Recognized Expert Contributor
            • Dec 2007
            • 750

            #6
            Welcome cmrhema! Do continue to post your queries on Bytes

            Comment

            Working...