Page 1 of 1
How to start app at Windows startup?
Posted: Thu Nov 19, 2009 9:46 am
by Srdjan
Hi
Is it possible to create app shortcut in Startup folder under Windows Start menu? I want to start my app everytime Windows start.
Thanks
Re: How to start app at Windows startup?
Posted: Thu Nov 19, 2009 10:32 am
by hliljegren
Srdjan wrote:Hi
Is it possible to create app shortcut in Startup folder under Windows Start menu? I want to start my app everytime Windows start.
Thanks
I'm not a Windows user but I can't see any reason why it should not work as Revolution apps are "ordinary" Windows apps, but then it starts at "login" and not at windows start-up. I guess there must be a registry setting you can use to auto-start your app also.
Posted: Thu Nov 19, 2009 10:44 am
by Srdjan
Well, you are right. I must correct myself. I need to start app at login

I think that copying app shortcut into Startup folder is the easiest way. I just want to find the way how to get Startup folder address and to place shortcut there.
Posted: Thu Nov 19, 2009 10:56 am
by Klaus
Hi Srdjan,
check this page for "specialfolderpath()" codes on Windows
http://www.sonsothunder.com/devres/revo ... ile010.htm
and then check "create alias" in the Rev documentation

"alias" = Shortcut!
Best
Klaus
Posted: Thu Nov 19, 2009 11:14 am
by SparkOut
http://www.sonsothunder.com/devres/revo ... ile010.htm is the bible for specialFolderPath codes.
If you put a shortcut to your program into specialFolderPath(7) then the application should run on startup of the correctly logged in user. To start up when any of the users of that machine logs in then you can use specialFolderPath(24).
To create the shortcut link you can use some vbscript:
Code: Select all
On Error Resume Next
result = "OK"
Set oWS = CreateObject("WScript.Shell")
If Err <> 0 then
result = "Error creating shell"
End If
If result = "OK" then
sLinkFile = "<path for the destination of the shortcut>.lnk"
Set oLink = oWS.CreateShortcut(sLinkFile)
If Err <> 0 then
result = "Error creating shortcut link file"
End If
End If
If result = "OK" then
oLink.TargetPath = "<path to your application>.exe"
oLink.Description = "<uh... a description>"
oLink.IconLocation = "<path to your icon file, which naturally will be the same as your application that has the embedded icon>.exe,0"
'the trailing 0 is the index number of the icon to use inside the icon file. I confess I
'don't know what the difference is when there's only one icon for your application.
'I have used index 0 or 1 interchangeably, while my applications contain 16 versions
'of the same icon at different sizes and bit depths. Windows seems to display the right
'resolution version of it whatever. At least for me, in my present experience.
oLink.WindowStyle = 1
oLink.Save
If Err <> 0 then
result = "Error creating shortcut icon"
End If
End If
Set oWS = nothing
If you replace the sLinkFile path with the value returned from specialFolderPath(7) then that will create your shortcut in the current user's startup path. You can place the link in other locations, by replacing that path with the value returned from another specialFolderPath, such as (16) for the user's desktop, or (23) for all users' desktops. Having replaced the correct values in the script, you can get RunRev to
and check the result to see what errors there may be - in theory, none, and you should find the shortcuts created in the correct location.
If you want the application to start without anyone having to log on, then you would need to install it as a service and/or mess with the registry.
HTH
SparkOut
Posted: Thu Nov 19, 2009 11:27 am
by SparkOut
Or of course (duh!) get RunRev to do the complicated stuff!
Code: Select all
put the defaultFolder into theFolder
set the defaultFolder to specialFolderPath(7)
create alias "MyShortcut.lnk" to file <path to my file>
'make sure you include the .lnk extension to the name on Windows
set the defaultFolder to theFolder
I must admit, I'd not got that to work properly with the icons before, but I just tested and it's fine. Will save me bothering in future!
Thanks Klausimausi!
Posted: Thu Nov 19, 2009 12:39 pm
by shadowslash
Hi srdjan,
You might wanna try making it run via the
registry. IMHO, its a more professional way of doing it... A quick code I can think of right about now is like below:
Code: Select all
get setRegistry("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\My_App",thePathToYourProgram)
Don't worry about messing up your registry, because you only need to change
My_App to your own liking then just
put the path of your program into the variable
thePathToYourProgram or just use your own. You don't need to mess with the other parts of the code.. ^^
Posted: Fri Nov 20, 2009 9:42 am
by Srdjan
Wow!
Thank you guys very much!
Now I need time to go thru all examples mentioned here.
Best regards
Posted: Fri Nov 20, 2009 10:54 am
by SparkOut
shadowslash wrote:You might wanna try making it run via the registry. IMHO, its a more professional way of doing it...
Not wishing to suggest there's anything wrong with your approach, but IMHO I don't think it can be claimed to be more professional. If anything, I would err on the side that it's more of a "quick and dirty" way, that is effective, but is rather reminiscent of "hacker techniques" and as such, could easily flag up as malware on the client system (as could any, of course, but I hope you see why I'm slightly dubious about starting something from the registry without going through a proper installation procedure).
Re: How to start app at Windows startup?
Posted: Fri Nov 20, 2009 9:03 pm
by jsims
Additionally, depending on the security environment the OP is deploying to, changes to the registry may very likely be locked out. However, it is usually less likely for the Startup folder to be locked down. At least, that has been my personal experience having worked in a pretty strict environment (Centers for Disease Control and Prevention).
Take care.