Get Installation Folder Path string in VB2010 Setup Project

127 views Asked by At

How can I get the installation folder path and put in a variable using VBScript?

enter image description here

My VBScript put files to certain folders and I want to do it dynamically.

2

There are 2 answers

1
PhilDW On BEST ANSWER

The answer is that you can't because Visual Studio setups don't have that capability. All custom actions, vbscripts, C++, C# or whatever all run after the files have been installed. There is no capability to run code before or during that UI sequence. If you want to get the location from somewhere on the system, setup projects have a search that might work to get the default value.

0
ladiesman1792 On

I did an alternative to this problem. I used Shell.BrowseForFolder method to browse for a folder and returned its path:

function fnShellBrowseForFolderVB()
        dim objShell
        dim ssfWINDOWS
        dim objFolder

        ssfWINDOWS = 36
        set objShell = CreateObject("shell.application")
            set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)
                if (not objFolder is nothing) then
                    'Add code here.
                end if
            set objFolder = nothing
        set objShell = nothing
    end function

Source: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

Hope this helps everyone.