/build/static/layout/Breadcrumb_cap_w.png

Change the start in folder of a shortcut

I am using Wise 5.51.

Doing a setup capture on an app with a shortcut start in folder set to H:\ (the users network home area). System variables exist of %HomeDrive% of H: and %HomePath% of \

The capture sets the start in folder as %HomeDrive%%HomePath% - seems fair enough and should give H:\ When I install the app, the shortcut start in folder reads C:\H:\\

In the Directory Table I modified the entry InstallPath92 from %HomeDrive%%HomePath% to H:\, but get the same result. I tried creating a StartinDir property of H:\ and setting StartinDir as the WkDir of the shortcut. Still get the same result.

Anybody know whats going here?

Thanks in advance

0 Comments   [ + ] Show comments

Answers (7)

Posted by: WiseUser 18 years ago
Fourth Degree Brown Belt
1
You're using a directory name rather than a property. Wise should fix their products so that you can select properties as well as directories from the "Installation Expert" interface.

Create a property called "WKDIR" or whatever, then give it a value of "%HomeDrive%%HomePath%", then type "WKDIR" in the appropriate column of the "Shortcut" table.

I believe that WI is appending "ROOTDRIVE" ("C:\") to your directory.
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Hello,

As you say "I tried creating a StartinDir property of H:\ and setting StartinDir as the WkDir of the shortcut" WILL work.

Try changing 'StartinDir' to capital letters.
Posted by: Lillude 18 years ago
Senior Purple Belt
0
In case its not working then you can add the link file (.Lnk) in your package as a shortcut and it will work. if you need to advertise that shortcut you add the link file to a new component and then create shortcut pointing to that link file and then advertise the new shortcut (the one pointing to the link file)
Posted by: glwday 18 years ago
Orange Belt
0
Thanks guys for your suggestions, I will keep trying to find one that works.
Posted by: jonasm 18 years ago
Blue Belt
0
In InstallShield you can make an Icon using VBScript in a Custom Action. I guess Wise has some kind of custom actions too.

For exampel:
-------------------------------------------------------
Set WshShell = CreateObject("WScript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")
on error resume next
strStartTopPath = WshShell.SpecialFolders("AllUsersPrograms")

fname=strStartTopPath & "\Adobe"
objFso.CreateFolder(fname)

Set objShortcutLnk = WshShell.CreateShortcut(strStartTopPath & "\Adobe\Adobe setup.lnk")

objShortcutLnk.TargetPath = "%Programfiles%\Adobe\Adobe.bat"
objShortcutLnk.WorkingDirectory = "%Programfiles%\Adobe"
objShortcutLnk.WindowStyle = 7 ' 1=Normalt, 3 = Max, 7 = Mini
objShortcutLnk.IconLocation = "%Programfiles%\Adobe\Adobe.EXE, 0"
objShortcutLnk.Save
-------------------------------------------------------

This will create a folder in the startmenu named Adobe, and a link named Adobe setup.

Remember that if you uninstalls the package, the Icon will still be on the startmenu.

/Jonas
Posted by: glwday 18 years ago
Orange Belt
0
Thanks Jonas

That looks interesting
Posted by: Regen 16 years ago
Senior Yellow Belt
0
I have been looking for a solution to the exactly the same problem as glwday above. I want to create a shortcut that has a "Start in:" value of the literal string %HOMEDRIVE%%HOMEPATH%, but I have not found one that works for me. In my case, if I set the shortcut to have a "Start in:" field of %HOMEDRIVE%%HOMEPATH% (using a Property as a facilitator for this) I found that when the MSI was installing, it would resolve %HOMEDRIVE%%HOMEPATH% to the value of the user account that was installing it (usually an administrator) and this would cause problems for all other users. When I could not find a working solution, I had to come up with my own. I will post it here in the hope that someone else finds it useful, as I always appreciate it when someone else does the same for me. Thanks go to jonasm for making me aware that VBScript can create shortcuts. I then discovered that VBScript can use the same function WshShell.CreateShortcut to edit a shortcut.

In summary, what I am doing is creating a shortcut as normal in the MSI with a blank "Start in:" field, and then using an embedded VBScript to edit it later in the install process. Doing it this way allows the shortcut to be uninstalled by the MSI (as it was originally created by the MSI) and avoids the issue of leaving the shortcut behind on uninstall as noted by jonasm.

Editing the shortcut needs to be done as a Execute Deferred custom action, so requires access to the MSI Properties during Deferred Execution. There is an excellent article on this at http://www.macrovision.com/webdocuments/CustomActionData.pdf.

I am using Windows Installer Editor from Wise Package Studio 5.6, so I will include detailed instructions on how to do it in this version. I am not sure about other MSI creation packages, as I have not used them, but the details should be similar. If you are advanced in MSI packaging, then you only need to read the major points {e.g. "2)" } and can skip the minor points {e.g. "2a)" }. For those of you who are not as advanced, or would like more detail, please read all lines. Sorry for the length of this post, but I wanted to provide full details for those new to packaging.

To modify "Start in:" of a shortcut
1) Create shortcut to "File in the installation" as per normal, and make the Working Directory <none> (empty).

2) Create a Property where the Name of the property EXACTLY matches (including upper/lowercase) the name of the Custom Action VBScript that we will create later.
Detailed steps to do this in WPS 5.6:
2a) Click on Setup Editor (down the bottom)
2b) Click on the Product tab (at the top)
2c) Click on Properties (on the left)
2d) In the right pane, right click and select New > Property
2e) Set the Name EXACTLY the same as the Custom Action VBScript that we will create in step 5 (e.g. ShortcutWkDir)
2f) Value can be anything, as it will be changed later. I have found that WPS throws an error if the Property Value is empty, so I just type in "blah" (without quotes).
2g) Click OK

3) Look up the name of the Directory key for the directory where the shortcut will be created
3a) Click on the Tables tab (at the top)
3b) Scroll down to Shortcut on the left and click on it
3c) Find your shortcut on the right. It is easiest to find if you look in the Name field
3d) Note the entry in the Directory_ field. We will need this in step 4.

4) Create a Execute Immediate Set Property custom action that sets the value of the Property we created above to the entry we found in the Directory_ field in step 3d above.
4a) Click on MSI Script (at the bottom)
4b) Click on the Execute Immediate tab (at the bottom)
4c) Scroll to somewhere after CostFinalize, InstallValidate and InstallInitialize but before CreateShortcuts and click on it. The line immediately above CreateShortcuts is usually a REM comment, so I click on this line to put my Custom Action immediately above that.
4d) Double click on Set Property on the left
4e) Give it a name. Can be anything, but I used SetProp_ShortcutWkDir.
4f) In the Property pull-down, select the Property we created in step 2e above (e.g. ShortcutWkDir)
4g) Set the Property Value to be the entry that was in the Directory_ field in step 3d above enclosed in square brackets []. In my test example, I am creating the shortcut in C:\Documents and Settings\All Users\Programs\test-menu, so when I looked up the Shortcut table, my entry in the Directory_ field was testmenu, so I would type [testmenu] into the Property Value field.
4h) Click OK

5) Create an Execute Deferred "Call VBScript from Embedded Code" custom action with the EXACT same name as the property created in step 2 above and paste into it the below code.
5a) Click on the Execute Deferred tab (at the bottom)
5b) Scroll down to below CreateShortcuts but before InstallFinalize. The line immediately below CreateShortcuts is usually a REM comment, so I click on this line to put my Custom Action immediately above that.
5c) Double click on "Call VBScript From Embedded Code" on the left
5d) Set the Custom Action Name to be the same as the Property created in step 2 above (e.g. ShortcutWkDir)
5e) Paste in the code below, but change the filename "cmd.exe test.lnk" to whatever the name of your shortcut will be (and make sure you include the ".lnk" as this is the true file extension of a shortcut that Windows does its best to hide)

--- Start of code ---
strShortcutDir = Session.Property("CustomActionData")
Set WshShell = CreateObject("WScript.Shell")
Set oShellLink = WshShell.CreateShortcut(strShortcutDir & "cmd.exe test.lnk")
oShellLink.WorkingDirectory = "%HOMEDRIVE%%HOMEPATH%"
oShellLink.Save
--- End of code ---

5f) Click OK

6) We only want this custom action to run if the component that contains the shortcut is going to be installed. We don't want the script running if an uninstall is happening, as it will create a wierd shortcut file that has no taget, only a "Start in:" directory. To do this, surround the VBScript custom action in a If ... then ... End set of statements. First we need to find the name of the component that contains the file we will be creating a shortcut to.
6a) Click on Setup Editor (at the bottom)
6b) Click on the Features tab (at the top)
6c) Expand the Feature that contains the shortcut we are creating, expand the Combined folder, and click on Shortcuts.
6d) On the right is a list of shortcuts that will be installed by this Feature. Find the relevant shortcut and note the entry in the Component_ field. We will need that in a moment. In my test example, the name of the component is cmd.exe, which just happens to be the name of the file I am installing as a test.
6e) Click on MSI Script (at the bottom)
6f) Make sure the custom action VBScript we created in step 5 is still selected.
6g) Double click on "If Statement" on the left
6h) Click on the button Build
6i) Click on Fields:Component, Values:cmd.exe (substitute the name of your component you found in step 6d) and State:Action, then click on the button Paste
6j) Click on the button >
6k) Double click on Absent (in "Install/Action state:"). You should now have something like "$cmd.exe > 2" at the top
6l) Click OK twice
6m) Click on the line immediately below your "Call VBScript From Embedded Code (ShortcutWkDir)"
6n) Double click on "End Statement" on the left.

You should now have something that looks like:

If $cmd.exe > 2 then
. Call VBScript From Embedded Code (ShortcutWkDir)
End

We are done. Save and compile your MSI! :-)

I hope this helps someone. If you feel so inclined, please post a note of thanks. I like to know when I have helped someone.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ