-
Aug 7th, 2020, 08:53 AM
#1
Thread Starter
Lively Member
Create Shortcut as Part of Installation Process for VB6 Program
As part of my Installation Process for a Program that I created, I would like to create a Shortcut to the Installed Executable on All Users Desktop. I modified Setup.lst, in the [Setup] Section, as indicated below, to force Installation to a Default Directory. The Application Name is predefined, and I know how to create the Shortcut via Windows Script Host. My question is where, exactly, do I place the Code to create this Shortcut? I'm assuming that I would need to insert the Code in the Load() Event of Setup1.frm, but not really sure. Thanks in advance.
Code:
[Setup]
Title=Where to put Shortcut
DefaultDir=$(ProgramFiles)\Where to put Shortcut
ForceUseDefDir=1
AppExe=Shortcut.exe
AppToUninstall=Shortcut.exe
-
Aug 9th, 2020, 09:06 AM
#2
Re: Create Shortcut as Part of Installation Process for VB6 Program
It has been a long time since I did this but here is a section of a setup.lst I used in the past
[IconGroups]
Group0=BIM
PrivateGroup0=0
Parent0=$(Programs)
Group1=Startup
PrivateGroup1=0
Parent1=$(Programs)
Group2=Desktop
PrivateGroup2=0
Parent2=$(Programs)
[BIM]
Icon1="CEServer.exe"
Title1=CE Server
StartIn1=$(AppPath)
[Startup]
Icon1="CEServer.exe"
Title1=Ce Server
StartIn1=$(AppPath)
Create Shortcut=Prompt
[Desktop]
Icon1="CEServer.exe"
Title1=Ce Server
StartIn1=$(AppPath)
Create Shortcut=Prompt
I think I also modified the PDwizard to make this work. It has been a while but I am pretty sure that during install it prompts the user to ask if they want it on the desktop and if they want it to run at startup. I'll see if I can locate the modified pdwizard code to see what I actually did to it to add this functionality.
-
Aug 9th, 2020, 09:12 AM
#3
Re: Create Shortcut as Part of Installation Process for VB6 Program
Ok I located the modified code. This is in the createicons section of the basSetup1.bas module of the Setup1 project under PDWizard.
Code:
If UCase(strGroup) = "DESKTOP" Then
strGroup = "..\..\Desktop"
waOptions = ReadIniFile(gstrSetupInfoFile, "Desktop", "Create ShortCut")
If UCase(waOptions) = "YES" Then
CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, fPrivate, sParent
ElseIf UCase(waOptions) = "PROMPT" Then
waOptions = CStr(MsgBox("Would you like a shortcut placed on the desktop?", vbQuestion + vbYesNo, "Create Shortcut?"))
If Val(waOptions) = vbYes Then
CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, fPrivate, sParent
End If
Else
'MsgBox "Desktop Result= " & waOptions
End If
ElseIf UCase(strGroup) = "STARTUP" Then
waOptions = ReadIniFile(gstrSetupInfoFile, "STARTUP", "Create ShortCut")
If UCase(waOptions) = "YES" Then
CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, fPrivate, sParent
ElseIf UCase(waOptions) = "PROMPT" Then
waOptions = CStr(MsgBox("Would you like a shortcut placed in the starup folder?", vbQuestion + vbYesNo, "Create Shortcut?"))
If Val(waOptions) = vbYes Then
CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, fPrivate, sParent
End If
Else
'MsgBox "Startup Result= " & waOptions
End If
Else
CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, fPrivate, sParent
End If
Maybe that can be of use to you
-
Aug 9th, 2020, 09:16 AM
#4
Re: Create Shortcut as Part of Installation Process for VB6 Program
It's funny, been so long since I made that change to the wizard I had forgotten about it. Haven't used that added functionality in years, may have if I had remembered it was there
-
Aug 9th, 2020, 09:48 AM
#5
Re: Create Shortcut as Part of Installation Process for VB6 Program
You modified setup1, not the Wizard. We don't have source code for the PDW itself.
Another option would be to use another tool, for example Visual Studio 6.0 Installer 1.1 which replaced the PDW for most packaging purposes back in 1999.
-
Aug 9th, 2020, 11:41 AM
#6
Thread Starter
Lively Member
Re: Create Shortcut as Part of Installation Process for VB6 Program
@DataMiser:
Thanks for your Reply, it will definitely be helpful. I wasn't exactly sure how to go about this so, prior to your Reply, I:
- Modified frmSetup1 by placing Code that creates a Shortcut on the Users Desktop in the Unload() Event.
- In this Event, I was assured that all processes have come to completion and the Global References that I needed (Destination Directory, Executable Name) are still retaining their Values.
- It was now a simple matter to create the Desktop Link as the last operation to be done prior to Unloading frmSetup1.
- I used a single line of Code prior to the Error Trap in frmSetup1_Unload() to call a Public Sub-Routine that uses CreateShellLink() to create the actual Link. As I stated earlier, most of my Users are not Computer savvy at all, which is why I felt a Shortcut on the Desktop was warranted.
- I tested this approach on XP thru Windows 10 and never had a problem. The one downside is that, if the User uninstalls the Program, which he/she must due with future Updates, an orphaned Shortcut remains. This is partially solved because during the creation of the Link, if a prior Link exists, it is deleted. There is the issue of the useless Link remaining on the Desktop after an Uninstall and prior to a Re-install of an Updated Version.
P.S. - The question now is should I keep the status quo, or modify Setup1.lst and basSetup1, neither of which were previously touched. What is your Expert Opinion?
-
Aug 9th, 2020, 11:55 AM
#7
Re: Create Shortcut as Part of Installation Process for VB6 Program
Well as you can see I choose to modify the setup.exe. The way I made changes to the code it doesn't do anything different than normal unless it sees those lines in the ini file and it can be set to create the icons automatically or to prompt to create them and do so only if the user wants them. It can do one or both locations or neither based on the what is in that setup.lst file so imo if you are using this as your installer this is a good way to go.
I also use the Visual studio installer for most of my projects but have a few that are still kicking and were done with pdw and a couple of really old ones that use an old version of Install Shield.
-
Aug 9th, 2020, 12:12 PM
#8
Thread Starter
Lively Member
Re: Create Shortcut as Part of Installation Process for VB6 Program
Originally Posted by DataMiser
Well as you can see I choose to modify the setup.exe. The way I made changes to the code it doesn't do anything different than normal unless it sees those lines in the ini file and it can be set to create the icons automatically or to prompt to create them and do so only if the user wants them. It can do one or both locations or neither based on the what is in that setup.lst file so imo if you are using this as your installer this is a good way to go.
I also use the Visual studio installer for most of my projects but have a few that are still kicking and were done with pdw and a couple of really old ones that use an old version of Install Shield.
Your approach is definitely the more professional one. For now, given the nature of the people who will be using the App, I'll keep what I have. For the future, I will definitely go with your suggestion. Just a couple of questions, please.
- If the User Uninstalls the App using your modifications, does the Shortcut in either location get removed also?
- How do you go about getting the Visual Studio Installer?
- Can a single entry in the [Desktop] Section exist or are all needed, as in:
Code:
[Desktop]
Create Shortcut=Prompt
-
Aug 9th, 2020, 12:55 PM
#9
Re: Create Shortcut as Part of Installation Process for VB6 Program
Not sure if they would be removed or not, never tested it, did not really matter one or the other.
The 1.1 version was only available for a short time. You may be able to find it on an archive site somewhere.
There are later versions that come with various versions of VB.Net
I'm not sure about the first three lines those are all info for the shortcut would have to study the code to see if they could be omitted. The 4th line must be there in order for the code I showed to create the shortcut. If omitted then that whole section is basically ignored.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|