2021-12-09 09:27:10 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Opens the temporary folder
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
This script launches the File Explorer showing the temporary folder.
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./open-temporary-folder
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz · License: CC0
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
#>
|
|
|
|
|
|
2021-12-09 16:36:44 +01:00
|
|
|
|
function GetTempDir {
|
2021-12-10 11:51:51 +01:00
|
|
|
|
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
|
|
|
|
|
if ("$env:TMP" -ne "") { return "$env:TMP" }
|
2021-12-09 16:36:44 +01:00
|
|
|
|
if ($IsLinux) { return "/tmp" }
|
2021-12-10 11:51:51 +01:00
|
|
|
|
return "C:\Temp"
|
2021-12-09 16:36:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-09 09:27:10 +01:00
|
|
|
|
try {
|
2021-12-10 11:51:51 +01:00
|
|
|
|
$Path = GetTempDir
|
|
|
|
|
if (-not(test-path "$Path" -pathType container)) {
|
|
|
|
|
throw "Temporary folder at 📂$Path doesn't exist (yet)"
|
2021-12-09 09:27:10 +01:00
|
|
|
|
}
|
2021-12-10 11:51:51 +01:00
|
|
|
|
& "$PSScriptRoot/open-file-explorer.ps1" "$Path"
|
2021-12-09 09:27:10 +01:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|