Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # chdir to the folder where this script is located
- Write-Host "Change dir to $PSScriptRoot"
- Cd $PSScriptRoot
- # delete the old extracted folder if exist
- if (Test-Path -Path "install") {
- Write-Host "Deleting old folder"
- Remove-Item -Recurse "install"
- }
- # grab newest version from download page
- $downloadpageurl = "https://www.ghisler.com/download.htm"
- Write-Host "Downloading newest url from $downloadpageurl"
- $downloadpage= Invoke-WebRequest -Uri $downloadpageurl
- $downloadurl = ($downloadpage.Links | where { $_.innertext -eq "64-bit version only" } ).href
- # download the file with Bits
- Write-Host "Downloading $downloadurl"
- Import-Module BitsTransfer
- Start-BitsTransfer -Source $downloadurl -Destination "totalcommander.exe"
- # first extract the self extracting zip/exe
- Write-Host "Extracting totalcommander.exe"
- Start-Process "$($env:tools)\7Zip\7za.exe" -ArgumentList "x totalcommander.exe -oinstall" -Wait
- cd install
- # second extract the files needed from the install.cab
- Write-Host "Extracting install.cab"
- Start-Process "$($env:tools)\7Zip\7za.exe" -ArgumentList "x install.cab -oinstall" -Wait
- cd install
- # delete the toolbars to prevent overwriting the custom versions
- Write-Host "Removing toolbars *.bar"
- Remove-Item *.bar
- # closing Total Commander
- $totalcmd = Get-Process "TOTALCMD64" -ErrorAction SilentlyContinue
- if ($totalcmd) {
- Write-Host "Closing TotalCommander"
- # try gracefully first
- $null = $totalcmd.CloseMainWindow()
- Sleep 2
- # if not closed, force the process to close
- if (!$totalcmd.HasExited) {
- $totalcmd | Stop-Process -Force
- Sleep 5
- }
- }
- # copy all the files to the folder of TotalCommander
- Write-Host "Updating $($env:tools)\TotalCommander"
- xcopy /e *.* "$($env:tools)\TotalCommander" /y
- if ($totalcmd)
- {
- # launch again
- start-process "$($env:tools)\TotalCommander\TotalCMD64.exe"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement