From 609329bd2dfc486487877ca0753fffc03a481901 Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Sun, 24 Dec 2017 13:09:41 +0100 Subject: [PATCH] Use fixed path to cmd.exe (#1921) * Use fixed path to cmd.exe * Use $env:COMSPEC instead of $env:WINDIR --- lib/git.ps1 | 2 +- lib/install.ps1 | 12 ++++++------ lib/psmodules.ps1 | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/git.ps1 b/lib/git.ps1 index a04ee3a38..81ba934f0 100644 --- a/lib/git.ps1 +++ b/lib/git.ps1 @@ -4,7 +4,7 @@ function git_proxy_cmd { if($proxy) { $cmd = "SET HTTPS_PROXY=$proxy&&SET HTTP_PROXY=$proxy&&$cmd" } - cmd /c $cmd + & "$env:COMSPEC" /c $cmd } function git_clone { diff --git a/lib/install.ps1 b/lib/install.ps1 index 67c64656d..66e90c583 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -364,7 +364,7 @@ function dl_urls($app, $version, $manifest, $architecture, $dir, $use_cache = $t try { rm -r -force "$dir\_tmp" -ea stop } catch [system.io.pathtoolongexception] { - cmd /c "rmdir /s /q $dir\_tmp" + & "$env:COMSPEC" /c "rmdir /s /q $dir\_tmp" } catch [system.unauthorizedaccessexception] { warn "Couldn't remove $dir\_tmp: unauthorized access." } @@ -744,10 +744,10 @@ function link_current($versiondir) { if(test-path $currentdir) { # remove the junction attrib -R /L $currentdir - cmd /c rmdir $currentdir + & "$env:COMSPEC" /c rmdir $currentdir } - cmd /c mklink /j $currentdir $versiondir | out-null + & "$env:COMSPEC" /c mklink /j $currentdir $versiondir | out-null attrib $currentdir +R /L return $currentdir } @@ -768,7 +768,7 @@ function unlink_current($versiondir) { attrib $currentdir -R /L # remove the junction - cmd /c rmdir $currentdir + & "$env:COMSPEC" /c "rmdir $currentdir" return $currentdir } return $versiondir @@ -1018,10 +1018,10 @@ function persist_data($manifest, $original_dir, $persist_dir) { # create link if (is_directory $target) { - cmd /c "mklink /j `"$source`" `"$target`"" | out-null + & "$env:COMSPEC" /c "mklink /j `"$source`" `"$target`"" | out-null attrib $source.FullName +R /L } else { - cmd /c "mklink /h `"$source`" `"$target`"" | out-null + & "$env:COMSPEC" /c "mklink /h `"$source`" `"$target`"" | out-null } } } diff --git a/lib/psmodules.ps1 b/lib/psmodules.ps1 index 1c27fe7e7..61aa6f2c7 100644 --- a/lib/psmodules.ps1 +++ b/lib/psmodules.ps1 @@ -24,10 +24,10 @@ function install_psmodule($manifest, $dir, $global) { if(test-path $linkfrom) { warn "$(friendly_path $linkfrom) already exists. It will be replaced." - cmd /c rmdir $linkfrom + & "$env:COMSPEC" /c "rmdir $linkfrom" } - cmd /c mklink /j $linkfrom $dir | out-null + & "$env:COMSPEC" /c "mklink /j $linkfrom $dir" | out-null } function uninstall_psmodule($manifest, $dir, $global) { @@ -41,7 +41,7 @@ function uninstall_psmodule($manifest, $dir, $global) { if(test-path $linkfrom) { write-host "Removing $(friendly_path $linkfrom)" $linkfrom = resolve-path $linkfrom - cmd /c rmdir $linkfrom + & "$env:COMSPEC" /c "rmdir $linkfrom" } }