Auto Launch Application After Installation

ImDaFrEaK

Well-known member
Joined
Jan 7, 2006
Messages
416
Location
California
Programming Experience
5-10
Hey, I am very nieve to Visual Studios Project Installer but I have been using it and making it work. BUT, I need to launch my application immediately after installation like the one step publisher does. I can't use that though b/c I am making new Registry keys ect... How do I use Project Installer and have it launch my newly installed program right after installation?
 
Found this (worked in VB2003 setup project)
Q: How do I automatically run my program after installation?
A: There is a way that might work, but it also might not work the way you expect.
1. Create a .vbs file with the following code.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """" & Property("CustomActionData") & """",7,False
Set WshShell = Nothing
2. Open your setup project and go to the Custom Actions Editor
3. Select the Commit Node and right-click, add a new Custom Action
4. Browse the filesystem to add the .vbs file from step 1
5. Edit the CustomActionData property and add the following:
[TARGETDIR]YourApp.exe
6. Change “YourApp.exe” to whatever your startup app file name is.
Note, you have to add the created .vbs to the setup projects filesystem application folder before you can browse and select it from Commit action.

If you tried running the primary output of application directly from Commit phase (works if you set the InstallerClass property False) the installer would not finish until app closed. It's something about return codes for the installer steps, and the script finishes and returns 'done' to installer after lauching the app.
 
Just a thought about ClickOnce and Registry keys. You can have an registry setting that you check on app startup, if this key don't exist you create your registry set. This is very inexpensive, but you have to write three lines of code for each key/name/value instead of using the VS MSI registry visual editor.
 
I have never programmed any coding that works with the registry and the books I've read didn't teach it. Can you maybe post some code writing the three lines? I would be very thankful.

Also I would like the user to be required to reboot but I don't see an easy way of accomplishing that either. Basically I have a program that runs in the background and hotkeys are pressed to run it. The program must run first on the Admin account during or after installation to build the proper directories so non-admin accounts won't recieve an error when running it. And also, I want the program to be running after installation which one prob be best offered with a reboot and the program auto running from the registry keys. I really need to get a book that teaches installation b/c I can build a nice windows app but I am clueless for the most part on how to properly install it. For example, I have the program checking for the serial key on first run but I would much rather use the built in feature during Project Installer to check that. But i don't know how.


But hey wow, that code above helped a lot for now. It runs right after install. So any code in Commit get's hit after install? What if I want to add extra clean up to the Un-install? Do I do that the same way? SO many questions huh, lol. Does it have to be VBScript or can I use a code file and just write it in VB? The first question is most important right now. Thanks :)
 
Last edited:
I have never programmed any coding that works with the registry and the books I've read didn't teach it. Can you maybe post some code writing the three lines?
Here is one of many VB.Net Registry tutorials, this one from Code Project (a great resource site!) http://www.codeproject.com/vb/net/registry_with_vb.asp

Basically working with registry in code you do each key and name/value pair, if it doesn't exist create it.

Also I would like the user to be required to reboot but I don't see an easy way of accomplishing that either.
This code should reboot Windows:
VB.NET:
Process.Start("Shutdown", "/r")

So any code in Commit get's hit after install? What if I want to add extra clean up to the Un-install? Do I do that the same way? SO many questions huh, lol. Does it have to be VBScript or can I use a code file and just write it in VB?
Commit happens after an install without errors. There is Uninstall custom action that can be used the same. The command can be any executable command, but as I said it waits for exit code so if you run an exe directly installation will not finish until the exe you ran is closed again. Running it through the script is a solution because the script can execute the application exe and don't wait for it to close, so the script will just run the commands and finish and report back to the installer it was finished.
 
I gotcha. Thanks a ton man. I know after hours of hunting and fishing I could have learned all this but I have a lot on my plate right now and you've been a really big help. I honestly appreciate it all.
 
Back
Top