Skip to content

Commit 795c611

Browse files
gpduckiSazonov
authored andcommitted
Adds script to patch the shortcut working directory to the user's home folder. (PowerShell#6043)
Update the shortcut created by the installer to use %HOMEDRIVE%%HOMEPATH% for the working directory.
1 parent bf69135 commit 795c611

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

assets/Product.wxs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
<!-- Default value of Checkbox of starting PowerShell after installation -->
4444
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
4545
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
46+
<CustomAction Id="SaveShortcutPath" Property="ShortcutPath" Value="[$ApplicationProgramsMenuShortcut]$(var.ProductSemanticVersionWithNameAndOptionalArchitecture).lnk" />
47+
<CustomAction Id="FixShortcutWorkingDirectory" Script="vbscript" HideTarget="no" Impersonate="no">
48+
shortcutPath = Session.Property("ShortcutPath")
49+
Set fso = CreateObject("Scripting.FileSystemObject")
50+
if (fso.FileExists(shortcutPath)) Then
51+
Set wshShell = CreateObject("WSCript.Shell")
52+
Set shortcut = wshShell.CreateShortcut(shortcutPath)
53+
54+
shortcut.workingdirectory = "%HOMEDRIVE%%HOMEPATH%"
55+
shortcut.save
56+
End If
57+
</CustomAction>
4658
<UI>
4759
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
4860
<Control Id="LaunchCheckBox" Type="CheckBox" X="10" Y="243" Width="170" Height="17" Property="LAUNCHAPPONEXIT" Hidden="yes" CheckBoxValue="1" Text="Launch $(env.ProductName)">
@@ -185,6 +197,12 @@
185197
</Directory>
186198
</Directory>
187199
</Directory>
200+
<InstallExecuteSequence>
201+
<Custom Action="SaveShortcutPath" After="InstallFinalize" />
202+
<Custom Action="FixShortcutWorkingDirectory" After="SaveShortcutPath">
203+
NOT Installed OR NOT REMOVE OR UPGRADINGPRODUCTCODE
204+
</Custom>
205+
</InstallExecuteSequence>
188206
</Product>
189207

190208
<!-- Explorer Context Menu Dialog -->

0 commit comments

Comments
 (0)