Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 28th October 2008, 18:27   #1
JonathansCorner
Junior Member
 
Join Date: Oct 2008
Posts: 5
Avoiding a bad way of starting an application on login / startup

I have a Tcl script that I want to provide a notification window when someone connects to a port it's listening to and provides specific information, and I'd like to have the script started when the user logs in, or possibly when the computer is started up.

I'd imagine that if I poked around other resources I could find a bad way to get it to work on my system... and wanted to ask people on this system, who probably know the right way, what's the "best engineering" approach in this case?

Jonathan
JonathansCorner is offline   Reply With Quote
Old 28th October 2008, 23:39   #2
AaronLS
Senior Member
 
Join Date: Mar 2008
Posts: 129
I'm unfamiliar with what a TCL script is, but if it is, or can be package in, an executable, then you can use the registry in windows to set it to run at startup. You can either do this for a particular user by adding a registry entry to HKCU, or do it for all users by adding it to HKLM

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

The other option is to place a shortcut into the "startup" folder of the start menu. Once again, you can do this under an individual user's start menu or the All Users startmenu.

If you want to make it easy for the user to enable/disable this feature, you should do it through the start menu.

The registry is probably the easier method though, and what I would go with. If I wanted to allow the user to disable the "Run at startup", then I'd provide a GUI that allows them to do that, and the application would remove the registry entry for them.

IMO it is a really awful practice to set a program to run at startup and not provide an obvious/intuitive way to let the user disable that feature. Additionally I'd say that the installer should even have a "Run at startup" checkbox so the user can disable the feature.

Oh, the other option is to install a Windows Service. One big difference will be that the above methods will not run the program until a user logs in. A windows Service can startup before anyone has even logged in, which is great if you need the application to run on a server, where users are not normally logged in.
AaronLS is offline   Reply With Quote
Old 29th October 2008, 13:11   #3
JonathansCorner
Junior Member
 
Join Date: Oct 2008
Posts: 5
TCL is a scripting language, something of a lesser-known cousin to Perl and Python--it is indeed an executable, although interpreted rather than being a standalone .exe.

So the installer, to work for the current user, should be something like:

WriteRegStr HKCU "Software\MicroSoft\Windows\CurrentVersion\Run" "${_APP_NAME}" "${_APP_NAME}"

Or is part of that a bit off?

Thanks for your help,
Jonathan
JonathansCorner is offline   Reply With Quote
Old 30th October 2008, 05:34   #4
AaronLS
Senior Member
 
Join Date: Mar 2008
Posts: 129
I think that's right, except the value parameter should be the full path to the executable, something like this I think:

WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${_APP_NAME}" "C:\blah\TLC.exe"

Edit: I'm not sure if registry keys are case sensitive, but I noticed you have MicroSoft instead of Microsoft. Thought I'd point that out if you have a problem.
AaronLS is offline   Reply With Quote
Old 30th October 2008, 12:10   #5
JonathansCorner
Junior Member
 
Join Date: Oct 2008
Posts: 5
Thanks you, in particular for the capitalization note.

Quote:
Originally posted by AaronLS
I think that's right, except the value parameter should be the full path to the executable, something like this I think:

WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${_APP_NAME}" "C:\blah\TLC.exe"

Edit: I'm not sure if registry keys are case sensitive, but I noticed you have MicroSoft instead of Microsoft. Thought I'd point that out if you have a problem.
JonathansCorner is offline   Reply With Quote
Old 10th December 2008, 21:22   #6
JonathansCorner
Junior Member
 
Join Date: Oct 2008
Posts: 5
Quote:
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${_APP_NAME}" "C:\blah\TLC.exe"
Followup question: How, in the uninstaller, do I delete the registry key or part of key created as quoted above?

Thanks,
Jonathan
JonathansCorner is offline   Reply With Quote
Old 10th December 2008, 22:24   #7
AaronLS
Senior Member
 
Join Date: Mar 2008
Posts: 129
Quote:
Originally posted by JonathansCorner
Followup question: How, in the uninstaller, do I delete the registry key or part of key created as quoted above?

Thanks,
Jonathan
According to the NSIS user manual section 4.9.2.4 it should be something like this:
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${_APP_NAME}"
AaronLS is offline   Reply With Quote
Old 11th December 2008, 13:26   #8
JonathansCorner
Junior Member
 
Join Date: Oct 2008
Posts: 5
Quote:
Originally posted by AaronLS
According to the NSIS user manual section 4.9.2.4 it should be something like this:
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "${_APP_NAME}"
Thank you!

Much appreciated,
JonathansCorner is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump