-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from Peefy/add-uninstall-documents
feat: add uninstall scripts and documents
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ------------------------------------------------------------ | ||
# Uninstallation script for KCL Binary | ||
# ------------------------------------------------------------ | ||
param ( | ||
[string]$KCLRoot = "$Env:SystemDrive\kclvm" | ||
) | ||
Write-Output "Starting KCL uninstallation..." | ||
$ErrorActionPreference = 'stop' | ||
|
||
# Constants | ||
$KCLCliFileName = "kcl.exe" | ||
$KCLCliFileBinPath = "${KCLRoot}\bin" | ||
$KCLCliFilePath = "${KCLCliFileBinPath}\${KCLCliFileName}" | ||
|
||
# Remove KCL binary files | ||
if (Test-Path $KCLCliFileBinPath) { | ||
Write-Output "Removing KCL files from $KCLCliFileBinPath" | ||
Remove-Item -Recurse -Force $KCLCliFileBinPath | ||
} else { | ||
Write-Output "KCL binary files not found. Skipping..." | ||
} | ||
|
||
# Remove KCL Root if it's empty | ||
if (Test-Path $KCLRoot) { | ||
if (!(Get-ChildItem -Path $KCLRoot -Recurse)) { | ||
Write-Output "Removing empty KCL Root directory: $KCLRoot" | ||
Remove-Item -Force $KCLRoot | ||
} else { | ||
Write-Output "KCL Root directory is not empty, skipping removal: $KCLRoot" | ||
} | ||
} | ||
|
||
# Remove KCLRoot from User Path environment variable | ||
Write-Output "Removing $KCLRoot from User Path Environment variable..." | ||
$UserPathEnvironmentVar = Environment::GetEnvironmentVariable("PATH", "User") | ||
if ($UserPathEnvironmentVar -like "*$KCLRoot*") { | ||
$NewUserPath = ($UserPathEnvironmentVar -split ';' | Where-Object { $_ -ne $KCLRoot -and $_ -ne $KCLCliFileBinPath }) -join ';' | ||
Environment::SetEnvironmentVariable("PATH", $NewUserPath, "User") | ||
Write-Output "KCL directory removed from User Path." | ||
} else { | ||
Write-Output "KCL directory not found in User Path. Skipping..." | ||
} | ||
|
||
Write-Output "KCL has been uninstalled successfully." | ||
Write-Output "Please restart your system or log off and on for the changes to take effect." |