Results 1 to 9 of 9

Thread: Create Shortcut as Part of Installation Process for VB6 Program

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2020
    Location
    Florida
    Posts
    93

    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

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2020
    Location
    Florida
    Posts
    93

    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:
    1. Modified frmSetup1 by placing Code that creates a Shortcut on the Users Desktop in the Unload() Event.
    2. 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.
    3. It was now a simple matter to create the Desktop Link as the last operation to be done prior to Unloading frmSetup1.
    4. 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.
    5. 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?

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2020
    Location
    Florida
    Posts
    93

    Re: Create Shortcut as Part of Installation Process for VB6 Program

    Quote Originally Posted by DataMiser View Post
    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.
    1. If the User Uninstalls the App using your modifications, does the Shortcut in either location get removed also?
    2. How do you go about getting the Visual Studio Installer?
    3. Can a single entry in the [Desktop] Section exist or are all needed, as in:
      Code:
      [Desktop]
      Create Shortcut=Prompt

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    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
  •  



Click Here to Expand Forum to Full Width