locked
Run on start up but quietly RRS feed

  • Question

  • i had made entries here ..

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

    like

    "C:\Program Files\TestApp\TestApp.exe" -quiet

     

    but stil it appears in front windows ..

    i want that wen windows reboot ..it will not appaer to front ..it goes to tray ......

     

    wat option i have to use or where i have to make entries......

    Regards,

    Aamir

     

    Thursday, July 26, 2007 2:24 PM

Answers

  •  AamirKhurshid wrote:

     

    no i m nt checking that tag ..how can i check ..i have no idea about to check the argument..

    wen i mention the registry entry with quiet it means that me passing quiet argument to main ..is it ..?

    really i hav nt much knowlge of that ..

    can u exaplain a bit more ..

     i m very near to solve the problem with the help of these two persons which are replying me..

    Waiting 4 ur kind reply ..

    regards,

    Aamir



    Hi Aamir,

    Yes, you are very near solving the problem. And again yes, you are passing an argument to main when you mention it in registry. You can access the arguments passed to the application either by the windows shortcut or command-line. Here is an example :

            static void Main(String[] args)
            {
                Boolean QuietLoad = false;

                foreach (String arg in args)
                {
                    if (arg.Equals("quiet", StringComparison.CurrentCultureIgnoreCase))
                    {
                        QuietLoad = true;
                        break;
                    }
                }

                Form1 MainForm = new Form1();

                if (QuietLoad)
                {
                    MainForm.Visible = false;
                }
                else
                {
                    // Nothing
                }

                Application.EnableVisualStyles();
                Application.Run(MainForm);
            }

    Adjust it your needs.
    Friday, July 27, 2007 2:33 PM

All replies

  • If the application is a winform then you need to

    1) Set the Visible property to false
    2) Set FormWindowState to minimize
    3) Set ShowInTaskbar to false.

    That will have the application nnot come up. This should be done regardless of when the application starts, whether at boot up or normally. I give an example of such a startup with the window hidden and now task button on my blog entitled, Creating a Application which Minimizes to a Tray Icon in .Net
    Thursday, July 26, 2007 3:51 PM
  •  

    When you have tray application, but you want to avoid anoying showing of application form which last for one tenth of second, but is still visible, you can solve it with simple trick, by setting Location of Form out of visible screen. So if Form is just a placeholder for Notify control with size 100x100, then set Location to -200, -200.
    Thursday, July 26, 2007 8:58 PM
  •  boban.s wrote:

     

    When you have tray application, but you want to avoid anoying showing of application form which last for one tenth of second, but is still visible, you can solve it with simple trick, by setting Location of Form out of visible screen. So if Form is just a placeholder for Notify control with size 100x100, then set Location to -200, -200.


    Nice thought, create it in the fourth dimension! <g>
    Thursday, July 26, 2007 9:11 PM
  • Boban,

     

    Would that trick still work with dual displays? Let say I extended my desktop to 2 monitors, would the left corner still be 0,0 if the secondary monitor was to the left of the primary display?

     

    Sorry if this is a noob question...

     

    Friday, July 27, 2007 1:14 AM
  •  Jeremy Filburn wrote:

    Boban,

     

    Would that trick still work with dual displays? Let say I extended my desktop to 2 monitors, would the left corner still be 0,0 if the secondary monitor was to the left of the primary display?

     

    Sorry if this is a noob question...

     



    Can't test , but i beleave it will work.

    Friday, July 27, 2007 6:51 AM
  •  

    Thanks boban.s and OmegaMan..

    OmegaMan: if i set visible to false then how it will load when i want to run the application. at load time it will be unvisible??

    Friday, July 27, 2007 8:24 AM
  •  AamirKhurshid wrote:

     

    Thanks boban.s and OmegaMan..

    OmegaMan: if i set visible to false then how it will load when i want to run the application. at load time it will be unvisible??



    Hi Aamir,

    When you load your application quietly and make the main form invisible by setting Visible = false, provide an option in the NotifyIcon tray icon's ContextMenu to show the form. For this you must use NotifyIcon, and it's not that difficult in .Net to use it.
    Friday, July 27, 2007 10:26 AM
  •  decyclone wrote:
     AamirKhurshid wrote:

     

    Thanks boban.s and OmegaMan..

    OmegaMan: if i set visible to false then how it will load when i want to run the application. at load time it will be unvisible??



    Hi Aamir,

    When you load your application quietly and make the main form invisible by setting Visible = false, provide an option in the NotifyIcon tray icon's ContextMenu to show the form. For this you must use NotifyIcon, and it's not that difficult in .Net to use it.


    I agree, in my example on my blog, Creating a Application which Minimizes to a Tray Icon in .Net,  I set it to visible which is kicked off after a resize event after the user clicks on the tray icon.
    Friday, July 27, 2007 10:41 AM
  •  

    hmmm thanks to both again ..

    i m already using notifyicon ...my application goes to tray as well .bt displayed on windows startup also ..

    as u suggest that to open it from notifyicon ..yes i have done it ..bt the problem exist that wen u click the Exe or the shorcut icon it will goes to tray instead of launch ..any idea to solve this issue ..

    Thanks 4 co operating me till yet ..hope to c u again ....

    Regards,

    Aamir

    Friday, July 27, 2007 11:54 AM

  • Are you checking the flag 'quiet' before setting the main form's Visible property to false? If the 'quiet' argument is passed in the Main(String[] args) function, then set the Visible propery to false, otherwise don't change it (true by default).

    See if this helps.
    Friday, July 27, 2007 1:33 PM
  •  

    no i m nt checking that tag ..how can i check ..i have no idea about to check the argument..

    wen i mention the registry entry with quiet it means that me passing quiet argument to main ..is it ..?

    really i hav nt much knowlge of that ..

    can u exaplain a bit more ..

     i m very near to solve the problem with the help of these two persons which are replying me..

    Waiting 4 ur kind reply ..

    regards,

    Aamir

    Friday, July 27, 2007 1:57 PM
  •  AamirKhurshid wrote:

     

    no i m nt checking that tag ..how can i check ..i have no idea about to check the argument..

    wen i mention the registry entry with quiet it means that me passing quiet argument to main ..is it ..?

    really i hav nt much knowlge of that ..

    can u exaplain a bit more ..

     i m very near to solve the problem with the help of these two persons which are replying me..

    Waiting 4 ur kind reply ..

    regards,

    Aamir



    Hi Aamir,

    Yes, you are very near solving the problem. And again yes, you are passing an argument to main when you mention it in registry. You can access the arguments passed to the application either by the windows shortcut or command-line. Here is an example :

            static void Main(String[] args)
            {
                Boolean QuietLoad = false;

                foreach (String arg in args)
                {
                    if (arg.Equals("quiet", StringComparison.CurrentCultureIgnoreCase))
                    {
                        QuietLoad = true;
                        break;
                    }
                }

                Form1 MainForm = new Form1();

                if (QuietLoad)
                {
                    MainForm.Visible = false;
                }
                else
                {
                    // Nothing
                }

                Application.EnableVisualStyles();
                Application.Run(MainForm);
            }

    Adjust it your needs.
    Friday, July 27, 2007 2:33 PM
  •  

    hi again ..decyclone

    it always come in Else portion.......

     

    i have this value in registry ...

    "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Run\Run\bin\Debug\Run.exe" -quiet

    here at this path HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

    now i had tried ur code but it always comes in else potion as argument not recieved..

    if (QuietLoad)

    {

    //Form1.Open = true;

    MainForm.Visible = false;

    }

    else

    {

    MessageBox.Show("Argument not receved.............");

    }

     

     

    am i missing some thing in registry ....

    Thanks again ....

    Regards,

    Aamir

    Saturday, July 28, 2007 7:28 AM
  •  

    ok its ok ...i just got it ..thanks Bro ...

    it was actually "-quiet" to compare ......

     

    i have marked it as answer ....

    Regards,

    Aamir

    Saturday, July 28, 2007 1:40 PM


  • Monday, July 30, 2007 7:52 AM
  •  

    When you have tray application, but you want to avoid anoying showing of application form which last for one tenth of second, but is still visible, you can solve it with simple trick, by setting Location of Form out of visible screen. So if Form is just a placeholder for Notify control with size 100x100, then set Location to -200, -200.
    In some situations this would not be sufficient, it would for instance hold open a citrix published application session even if it was ment to be a background app.
    Friday, October 8, 2010 2:11 AM