From a8fe94cbf6cf8ada1fc125c27520abd18f8562da Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Wed, 5 Dec 2018 09:36:35 -0500 Subject: [PATCH] (GH-1687) Allow env var in shortcut working dir This will allow environment variables in shortcut working directory. Environment variables will be kept in shortcut file, and be expanded by Windows in runtime. This is useful when creating Start-menu items for multi-user system. --- .../helpers/functions/Install-ChocolateyShortcut.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 index 446eb516f3..9af7438d00 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyShortcut.ps1 @@ -45,6 +45,9 @@ The full absolute path to the target for new shortcut. OPTIONAL - The full absolute path of the Working Directory that will be used by the new shortcut. +As of v0.10.12, the directory will be created unless it contains environment +variable expansion like `%AppData%\FooBar`. + .PARAMETER Arguments OPTIONAL - Additonal arguments that should be passed along to the new shortcut. @@ -164,7 +167,7 @@ Install-ChocolateyPinnedTaskBarItem } if ($workingDirectory) { - if (!(Test-Path($workingDirectory))) { + if ($workingDirectory -notmatch '%\w+%' -and !(Test-Path($workingDirectory))) { [System.IO.Directory]::CreateDirectory($workingDirectory) | Out-Null } }