FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lpython/uninstall-lpython.ps1 at main · AlHeloween/lpython · GitHub
AlHeloween
/
lpython
Public
forked from
lcompilers/lpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lpython
/
uninstall-lpython.ps1
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (37 loc) · 1.55 KB
Breadcrumbs
lpython
/
uninstall-lpython.ps1
Copy path
File metadata and controls
48 lines (37 loc) · 1.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
param
(
[
ValidateSet
(
"
User
"
,
"
Machine
"
,
"
Process
"
,
"
None
"
)]
[
string
]
$PathScope
=
"
User
"
)
$ErrorActionPreference
=
"
Stop
"
function
Get-PathEntries
([
string
]
$PathValue
) {
if
([
string
]::IsNullOrWhiteSpace(
$PathValue
)) {
return
@
()
}
return
@
(
$PathValue
.Split
(
'
;
'
)
|
Where-Object
{
-not
[
string
]::IsNullOrWhiteSpace(
$_
) })
}
function
Test-IsAdmin
{
$identity
=
[
Security.Principal.WindowsIdentity
]::GetCurrent()
$principal
=
New-Object
Security.Principal.WindowsPrincipal(
$identity
)
return
$principal
.IsInRole
([
Security.Principal.WindowsBuiltInRole
]::Administrator)
}
function
Remove-PathEntry
([
string
]
$Scope
,
[
string
]
$Entry
) {
if
(
$Scope
-eq
"
None
"
) {
return
}
if
(
$Scope
-eq
"
Machine
"
-and
-not
(
Test-IsAdmin
)) {
throw
"
Machine-scope uninstall requires an elevated PowerShell session.
"
}
if
(
$Scope
-eq
"
Process
"
) {
$entries
=
Get-PathEntries
$
env:
Path
$
env:
Path
=
((
$entries
|
Where-Object
{
$_
-ne
$Entry
})
-join
'
;
'
)
return
}
$currentPath
=
[
Environment
]::GetEnvironmentVariable(
"
Path
"
,
$Scope
)
$entries
=
Get-PathEntries
$currentPath
[
Environment
]::SetEnvironmentVariable(
"
Path
"
,
((
$entries
|
Where-Object
{
$_
-ne
$Entry
})
-join
'
;
'
)
,
$Scope
)
}
$InstallRoot
=
Split-Path
-
Parent
$MyInvocation
.MyCommand.Path
$BinDir
=
Join-Path
$InstallRoot
"
bin
"
Remove-PathEntry
-
Scope
$PathScope
-
Entry
$BinDir
Write-Host
"
Removed PATH entry for
$BinDir
from scope '
$PathScope
'.
"
Write-Host
"
Delete '
$InstallRoot
' manually if you want to remove the installed files.
"
Back
|
FazBrowse Home
|
New Git URL