View Full Version : [DATABASEDIR] set to drive root not installing files

02-04-2003, 11:27 AM
I have an install that calls a VBScript. The VBScript searches the computer for a previous installation, and if found, modifies [INSTALLDIR] and [DATABASEDIR].

The default for [DATABASEDIR] is [CommonAppDataFolder]. My database files get installed in [DATABASEDIR]CompanyName\ProductName\Data. If the script finds a previous version, [DATABASEDIR] is set to the root drive of the location where the previous version was found.

A similar process occurs with [INSTALLDIR].

When the script does not find a previous installation, both the program files and database files get installed correctly.

When the script finds a previous installation, only the program files are installed. The database files are not installed at all. I am wondering if this is because [DATABASEDIR] is set to a drive root (even though the actual files go in a subdirectory).

02-04-2003, 06:19 PM
The files should get installed SOMEWHERE even if DATABASEDIR is incorrectly configured by your VBScript. Do you think the feature that has the files in DATABASEDIR is not getting installed? Could you post your VBScript here so that I can take a look?

02-04-2003, 06:43 PM
There was only one feature, Always Install. The files couldn't be found anywhere but the source directory (installing on same machine I'm developing on).

However, I have managed to get around the problem with a different way to handle DATABASEDIR that doesn't cause the problem.

My VBScript follows, with the names altered slightly, but you'll get the picture.

- - - Begin Script - - -

' Set these constants for each installation project
Const CompanyName = "Company Name"
Const ProductName = "Product Name"
' These are the names of the directories in the database. They are
' set by creating them and defining the names in the
' Browse For Shortcut Target screen (why there, I don't know)
Const SharedDirectoryName1 = "SHARED1"
Const SharedDirectoryName2 = "SHARED2"
Const SharedDirectoryName3 = "SHARED3"
Const SharedDirectoryName4 = "SHARED4"
Const SharedDirectoryName5 = "SHARED5"
' These are the folder names for the shared directories. They
' will all fall under the Common directory, set later.
Const SharedDirectory1 = "Shared Directory 1"
Const SharedDirectory2 = "Shared Directory 2"
Const SharedDirectory3 = "Shared Directory 3"
Const SharedDirectory4 = "Shared Directory 4"
Const SharedDirectory5 = "Shared Directory 5"

' These variables should not be modified
Dim ProgramName
ProgramName = ProductName & ".exe"
Dim ProgramFolder
ProgramFolder = CompanyName & "\" & ProductName & "\"
' Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
' Dim Drives
Set Drives = FSO.Drives
Dim FoundFolder
FoundFolder = ""
Dim WindVol
WindVol = Session.property("WindowsVolume")

' Subroutine for recursive search for ProgramName

Sub FindFilePath(ByRef fld)
If FSO.FileExists(fld & "\" & ProgramName) then
FoundFolder = fld & "\"
For Each fld In fld.SubFolders
If Len(FoundFolder) then
Exit For
End If
End If
End Sub

If FSO.FileExists(WindVol & ProgramFolder & ProgramName) then
FoundFolder = WindVol & ProgramFolder
If FSO.FileExists(Session.TargetPath("INSTALLDIR") & ProgramName ) then
FoundFolder = Session.TargetPath("INSTALLDIR")
For Each DiskDrive In Drives
DriveType = DiskDrive.DriveType
If DriveType = 2 then
FindFilePath( FSO.GetFolder(DiskDrive.RootFolder) )
If Len(FoundFolder ) then
Exit For
End If
End If
End If
End If

If Len(FoundFolder ) then
If FoundFolder <> Session.TargetPath("INSTALLDIR") then
Session.TargetPath("INSTALLDIR") = FoundFolder
Session.Property("DATABASEDIR") = FoundFolder & "Data\"
Session.Property("COMMON") = Left(FoundFolder, 1) & ":\" & CompanyName & "\Common\"
Session.Property(SharedDirectoryName1) = Session.Property("COMMON") & SharedDirectory1 & "\"
Session.Property(SharedDirectoryName2) = Session.Property("COMMON") & SharedDirectory2 & "\"
Session.Property(SharedDirectoryName3) = Session.Property("COMMON") & SharedDirectory3 & "\"
Session.Property(SharedDirectoryName4) = Session.Property("COMMON") & SharedDirectory4 & "\"
Session.Property(SharedDirectoryName5) = Session.Property("COMMON") & SharedDirectory5 & "\"
End If
Session.Property("DATABASEDIR") = Session.Property("DATABASEDIR") & ProgramFolder
End If