From 2efc0f5ad6d0ff73ad4b0925a6cbd13ddbf127e4 Mon Sep 17 00:00:00 2001 From: Iristyle Date: Mon, 8 Apr 2013 17:54:02 -0400 Subject: [PATCH] fix(SublimeText2.UtilPackages): default ps paths - When searching for Powershell, be more resilient, search on disk for known locations and fallback to sensible default --- .../tools/chocolateyInstall.ps1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 index e1c07f1..2985836 100644 --- a/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 +++ b/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 @@ -23,7 +23,18 @@ try { $sublimeFiles = Join-Path (Get-CurrentDirectory) $sublimeFilesFileName # TODO: this doesn't actually work in the Sublime plugin right now, but might in the future - $ps = (Which powershell) + $systemPath = [Environment]::GetFolderPath('System') + $psDefault = Join-Path $systemPath 'WindowsPowerShell\v1.0\powershell.exe' + $ps = (Which powershell), + $psDefault | + ? { Test-Path $_ } | + Select -First 1 + if (!$ps) + { + Write-Warning "Could not find Powershell - using default $psDefault" + $ps = $psDefault + } + $psRoot = Split-Path $ps $escapedPs = $ps -replace '\\', '\\'