Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Creating shortcuts


1 reply to this topic

dimitri

dimitri
  • Members
  • 3 posts

Posted 31 January 2002 - 12:44

Hi,

We are trying to create a new installation using Installshield for Windows Installer. In previous installations we used to create shortcuts on the user's machine. If the target machine runs NT/2000/XP we created shortcuts with as working folder the literal string: %HOMEDRIVE%%HOMEPATH%.
Then any logged on user would always start in his or her homedirectory on the machine.

Now, using Windows Installer, we tried everything, but we always seem to end up with either an error during installation, or with an expanded homedirectory (i.e. the one of the user who has installed the product).

Does anyone know how to get the literal string %HOMEDRIVE%%HOMEPATH% in the working directory of the shortcut, so it is expanded when the user clicks the shortcut?

Dimitri


Brian Elliott

Brian Elliott
  • Members
  • 5 posts

Posted 31 January 2002 - 21:52

Hello Dimitri,

I'm not sure if this solution will work for you, but give it a try.  I have two VBScript CA's.  One adds shortcuts, the other (on an uninstall) goes thru and removes any.  Here is the VBScript code for adding the shortcuts.... try replacing a few of the lines appropriate to your install and then call the CA at the end of the install (hooked to the Finish button).
'----------------------------------
On error resume next
'Setup some defaults
Set WshShell = CreateObject ("WScript.Shell")
Set WshEnvironment = WshShell.Environment("process")
Set fsoLog = CreateObject("Scripting.FileSystemObject")
'Get the temp directory & start the log
strTempDir = WshEnvironment("TEMP")
Set logFile = fsoLog.CreateTextFile ( strTempDir & "\AddDesktopShortcut.txt", TRUE)
bError = False

logFile.WriteLine "Log Started: " & now
logFile.WriteLine "Install File"

strLink = WshShell.SpecialFolders("Desktop") & "\LinkName.lnk"
logFile.WriteLine strLink

strPath = WshShell.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\EXENAME.exe\Path")
if strPath = "" then
logFile.WriteLine "Error locating registry entry for EXENAME.exe"
bError = True
end if

logFile.WriteLine strPath

if Right(strPath, 1) = "\" then
strExePath = strPath & "EXENAME.exe"
else
strExePath = strPath & "\EXENAME.exe"
end if

logFile.WriteLine strExePath

if not bError then
set WshShortCut = WshShell.CreateShortcut(strLink)
WshShortCut.Description = "Description of your shortcut"
WshShortCut.IconLocation = strExePath & ", 0"
WshShortCut.TargetPath = strExePath
WshShortCut.WorkingDirectory = strPath
WshShortCut.WindowStyle = 1

WshShortCut.Save
end if
'------------------------------------------
Hope this helps, Bri