Skip to content

Commit

Permalink
detect store-installed powershell - fixes #5212
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Dec 23, 2021
1 parent d644c29 commit 0c60159
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tabby-local/src/shells/windowsStock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,22 @@ export class WindowsStockShellsProvider extends ShellProvider {
}

private async getPowerShellPath () {
const ps = 'powershell.exe'

if (!await promisify(hasbin)(ps)) {
for (const searchPath of [
`${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0`,
`${process.env.SystemRoot}\\System32`,
process.env.SystemRoot ?? 'C:\\Windows',
]) {
const newPath = path.join(searchPath, ps)
try {
await fs.stat(newPath)
return newPath
} catch { }
for (const name of ['pwsh.exe', 'powershell.exe']) {
if (await promisify(hasbin)(name)) {
return name
}
}
return ps
for (const psPath of [
`${process.env.USERPROFILE}\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe`,
`${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,
`${process.env.SystemRoot}\\System32\\powershell.exe`,
(process.env.SystemRoot ?? 'C:\\Windows') + '\\powerhshell.exe',
]) {
try {
await fs.stat(psPath)
return psPath
} catch { }
}
return 'powershell.exe'
}
}

0 comments on commit 0c60159

Please sign in to comment.