Update install-vlc.ps1 and uninstall-vlc.ps1

This commit is contained in:
Markus Fleschutz 2023-08-07 19:27:05 +02:00
parent 16bb5e7fdb
commit 2bf289b8ea
2 changed files with 16 additions and 8 deletions

View File

@ -5,6 +5,8 @@
This PowerShell script installs the VLC media player. This PowerShell script installs the VLC media player.
.EXAMPLE .EXAMPLE
PS> ./install-vlc.ps1 PS> ./install-vlc.ps1
Installing VLC media player...
Installation of VLC media player took 25 sec
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -12,12 +14,14 @@
#> #>
try { try {
"Installing VLC media player, please wait..." "⏳ Installing VLC media player..."
$StopWatch = [system.diagnostics.stopwatch]::startNew()
& winget install --id VideoLAN.VLC --accept-package-agreements --accept-source-agreements & winget install --id XPDM1ZW6815MQM --accept-package-agreements --accept-source-agreements
if ($lastExitCode -ne "0") { throw "'winget install' failed" } if ($lastExitCode -ne "0") { throw "Can't install VLC media player, is it already installed?" }
"VLC media player installed successfully." [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ Installation of VLC media player took $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,9 @@
.DESCRIPTION .DESCRIPTION
This PowerShell script uninstalls the VLC media player from the local computer. This PowerShell script uninstalls the VLC media player from the local computer.
.EXAMPLE .EXAMPLE
PS> ./uninstall-vlc PS> ./uninstall-vlc.ps1
Uninstalling VLC media player...
Removal of VLC media player took 7 sec
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -12,12 +14,14 @@
#> #>
try { try {
"Uninstalling VLC media player, please wait..." "⏳ Uninstalling VLC media player..."
$StopWatch = [system.diagnostics.stopwatch]::startNew()
& winget uninstall "VLC" & winget uninstall --id XPDM1ZW6815MQM
if ($lastExitCode -ne "0") { throw "Can't uninstall VLC media player, is it installed?" } if ($lastExitCode -ne "0") { throw "Can't uninstall VLC media player, is it installed?" }
"VLC media player is uninstalled now." [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ Removal of VLC media player took $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"Sorry: $($Error[0])" "Sorry: $($Error[0])"