Welcome to Dream.In.Code
Click Here
Getting VB.NET Help is Easy!

Join 118,655 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 892 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Problem with starting application at windows start

 
Reply to this topicStart new topic

Problem with starting application at windows start

nbarten
post 26 Jun, 2008 - 05:30 AM
Post #1


D.I.C Head

**
Joined: 30 Apr, 2007
Posts: 112



Thanked 1 times
My Contributions


Hi all. Got a nasty problem here.

I've made a windows service for the purpose of creating backup's of certain files and directories automatically each day. The service is installed as automatic (so it starts after win startup) and i have an application which monitors the service through a system tray icon (so right-click on it you can start/stop/pause the service, change settings, etc).

Now i wanted after the setup some settings made that the control application (with system tray icon) is started at windows startup.

So, i thought, the best way is to write in the registry (HKEY_LOCAL_MACHINE->SOFTWARE->MICROSOFT->WINDOWS->CurrentVersion->Run) a value with the shortcut to the installed application. I wrote the code that after the installation the correct path was written in the registry.

Unfortunately, it didn't work. The weird thing was, that when i looked at the task manager, that the process was started, but i didn't see the system tray icon.

Well, i thought: the other solution, just create a shortcut to the application in the win startup folder. But when i did it so that the shorcut was automatically made after the install, it was the same result: process started, but no system tray icon.

The very weird thing was this: if i manually created a shortcut to the application after the installation, it did work.

So somebody else here have maybe experience with this?
User is offlineProfile CardPM

Go to the top of the page


gbertoli3
post 30 Jun, 2008 - 08:09 AM
Post #2


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 812



Thanked 12 times

Dream Kudos: 750
My Contributions


QUOTE(nbarten @ 26 Jun, 2008 - 05:30 AM) *

Hi all. Got a nasty problem here.

I've made a windows service for the purpose of creating backup's of certain files and directories automatically each day. The service is installed as automatic (so it starts after win startup) and i have an application which monitors the service through a system tray icon (so right-click on it you can start/stop/pause the service, change settings, etc).

Now i wanted after the setup some settings made that the control application (with system tray icon) is started at windows startup.

So, i thought, the best way is to write in the registry (HKEY_LOCAL_MACHINE->SOFTWARE->MICROSOFT->WINDOWS->CurrentVersion->Run) a value with the shortcut to the installed application. I wrote the code that after the installation the correct path was written in the registry.

Unfortunately, it didn't work. The weird thing was, that when i looked at the task manager, that the process was started, but i didn't see the system tray icon.

Well, i thought: the other solution, just create a shortcut to the application in the win startup folder. But when i did it so that the shorcut was automatically made after the install, it was the same result: process started, but no system tray icon.

The very weird thing was this: if i manually created a shortcut to the application after the installation, it did work.

So somebody else here have maybe experience with this?



Hope this helps.


Make sure that you have:
CODE

Imports Microsoft.Win32


After that you can add the code. Put this in the FormClosing() Event.
CODE

        Dim regkey As RegistryKey
        regkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", True)
        If (runOnStartupToolStripMenuItem.Checked = True) Then
            ' Add the value in the registry so that the application runs at startup
            regkey.SetValue("Your Application Name", Application.ExecutablePath.ToString())
        Else
            ' Remove the value from the registry so that the application doesn't start
            regkey.DeleteValue("Your Application Name", False)
        End If


This post has been edited by gbertoli3: 30 Jun, 2008 - 02:45 PM
User is offlineProfile CardPM

Go to the top of the page

nbarten
post 30 Jun, 2008 - 11:46 PM
Post #3


D.I.C Head

**
Joined: 30 Apr, 2007
Posts: 112



Thanked 1 times
My Contributions


gbertoli3, thanks for your answer, but i have that already. It writes the correct url path succesfully to the Run key in the registry.

I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Same as creating a shortcut after setup automatically (the auto-created shortcut won't work (process started but no icon), but when i create manually a shortcut it works).

This post has been edited by nbarten: 30 Jun, 2008 - 11:46 PM
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 30 Jun, 2008 - 11:57 PM
Post #4


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 812



Thanked 12 times

Dream Kudos: 750
My Contributions


QUOTE(nbarten @ 30 Jun, 2008 - 11:46 PM) *

gbertoli3, thanks for your answer, but i have that already. It writes the correct url path succesfully to the Run key in the registry.

I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Same as creating a shortcut after setup automatically (the auto-created shortcut won't work (process started but no icon), but when i create manually a shortcut it works).


Oh ok
Do need anymore help with vb, vb.net, c#, c++, html, javascript, css?

User is offlineProfile CardPM

Go to the top of the page

nbarten
post 1 Jul, 2008 - 04:53 AM
Post #5


D.I.C Head

**
Joined: 30 Apr, 2007
Posts: 112



Thanked 1 times
My Contributions


no... still got only this problem
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 1 Jul, 2008 - 09:57 AM
Post #6


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 812



Thanked 12 times

Dream Kudos: 750
My Contributions


QUOTE(nbarten @ 1 Jul, 2008 - 04:53 AM) *

no... still got only this problem



So what is your problem exactly
User is offlineProfile CardPM

Go to the top of the page

nbarten
post 2 Jul, 2008 - 08:11 AM
Post #7


D.I.C Head

**
Joined: 30 Apr, 2007
Posts: 112



Thanked 1 times
My Contributions


Please read my other post:

QUOTE
I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Same as creating a shortcut after setup automatically (the auto-created shortcut won't work (process started but no icon), but when i create manually a shortcut it works).
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 2 Jul, 2008 - 08:20 AM
Post #8


DICula

Group Icon
Joined: 29 May, 2008
Posts: 614



Thanked 38 times

Dream Kudos: 2000
My Contributions


QUOTE(nbarten @ 2 Jul, 2008 - 04:11 PM) *

Please read my other post:

QUOTE
I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Same as creating a shortcut after setup automatically (the auto-created shortcut won't work (process started but no icon), but when i create manually a shortcut it works).



How are you starting the process? (Please could you show how.)
I'm thinking that they be a parameter missing.

Also are two parts?
1) The process
2) The application that monitor the process

Which is not starting?

This post has been edited by AdamSpeight2008: 2 Jul, 2008 - 08:24 AM
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 2 Jul, 2008 - 10:04 AM
Post #9


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,812



Thanked 27 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


QUOTE
I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Start the Task Manager after startup and check if the application's process is still running.
If it isn't there, the system tray is missing because your app abruptly shut down.
User is offlineProfile CardPM

Go to the top of the page

nbarten
post 4 Jul, 2008 - 02:12 AM
Post #10


D.I.C Head

**
Joined: 30 Apr, 2007
Posts: 112



Thanked 1 times
My Contributions


QUOTE(born2c0de @ 2 Jul, 2008 - 10:04 AM) *

QUOTE
I tried it with a normal windows application, and it worked perfectly. But when i try it with my current application, the process of the application seems to start (application started then?) but the system tray icon don't show up.

Start the Task Manager after startup and check if the application's process is still running.
If it isn't there, the system tray is missing because your app abruptly shut down.


Well, that's the weird thing. The proces is still running, but i don't see the system tray icon... while i manually start the application, it works fine.

Never had this problem before.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/12/08 03:22AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month