Skip to content

Commit

Permalink
Adds script to patch the shortcut working directory to the user's hom…
Browse files Browse the repository at this point in the history
…e folder. (PowerShell#6043)

Update the shortcut created by the installer to use %HOMEDRIVE%%HOMEPATH% for the working directory.
  • Loading branch information
gpduck authored and iSazonov committed Jan 31, 2018
1 parent bf69135 commit 795c611
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions assets/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
<!-- Default value of Checkbox of starting PowerShell after installation -->
<Property Id="WixShellExecTarget" Value="[$(var.ProductVersionWithName)]pwsh.exe"/>
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<CustomAction Id="SaveShortcutPath" Property="ShortcutPath" Value="[$ApplicationProgramsMenuShortcut]$(var.ProductSemanticVersionWithNameAndOptionalArchitecture).lnk" />
<CustomAction Id="FixShortcutWorkingDirectory" Script="vbscript" HideTarget="no" Impersonate="no">
shortcutPath = Session.Property("ShortcutPath")
Set fso = CreateObject("Scripting.FileSystemObject")
if (fso.FileExists(shortcutPath)) Then
Set wshShell = CreateObject("WSCript.Shell")
Set shortcut = wshShell.CreateShortcut(shortcutPath)

shortcut.workingdirectory = "%HOMEDRIVE%%HOMEPATH%"
shortcut.save
End If
</CustomAction>
<UI>
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
<Control Id="LaunchCheckBox" Type="CheckBox" X="10" Y="243" Width="170" Height="17" Property="LAUNCHAPPONEXIT" Hidden="yes" CheckBoxValue="1" Text="Launch $(env.ProductName)">
Expand Down Expand Up @@ -185,6 +197,12 @@
</Directory>
</Directory>
</Directory>
<InstallExecuteSequence>
<Custom Action="SaveShortcutPath" After="InstallFinalize" />
<Custom Action="FixShortcutWorkingDirectory" After="SaveShortcutPath">
NOT Installed OR NOT REMOVE OR UPGRADINGPRODUCTCODE
</Custom>
</InstallExecuteSequence>
</Product>

<!-- Explorer Context Menu Dialog -->
Expand Down

0 comments on commit 795c611

Please sign in to comment.