Advertisement
easternnl

TotalCommander Update Script

Jul 13th, 2018
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # chdir to the folder where this script is located
  2. Write-Host "Change dir to $PSScriptRoot"
  3. Cd $PSScriptRoot
  4.  
  5. # delete the old extracted folder if exist
  6. if (Test-Path -Path "install") {
  7.     Write-Host "Deleting old folder"
  8.     Remove-Item -Recurse "install"
  9. }
  10.  
  11. # grab newest version from download page
  12. $downloadpageurl = "https://www.ghisler.com/download.htm"
  13. Write-Host "Downloading newest url from $downloadpageurl"
  14. $downloadpage= Invoke-WebRequest -Uri $downloadpageurl
  15. $downloadurl = ($downloadpage.Links | where { $_.innertext -eq "64-bit version only" } ).href
  16.  
  17. # download the file with Bits
  18. Write-Host "Downloading $downloadurl"
  19. Import-Module BitsTransfer
  20. Start-BitsTransfer -Source $downloadurl -Destination "totalcommander.exe"
  21.  
  22. # first extract the self extracting zip/exe
  23. Write-Host "Extracting totalcommander.exe"
  24. Start-Process "$($env:tools)\7Zip\7za.exe" -ArgumentList "x totalcommander.exe -oinstall" -Wait
  25. cd install
  26.  
  27. # second extract the files needed from the install.cab
  28. Write-Host "Extracting install.cab"
  29. Start-Process "$($env:tools)\7Zip\7za.exe" -ArgumentList "x install.cab -oinstall" -Wait
  30. cd install
  31.  
  32. # delete the toolbars to prevent overwriting the custom versions
  33. Write-Host "Removing toolbars *.bar"
  34. Remove-Item *.bar
  35.  
  36. # closing Total Commander
  37. $totalcmd = Get-Process "TOTALCMD64" -ErrorAction SilentlyContinue
  38. if ($totalcmd) {
  39.     Write-Host "Closing TotalCommander"
  40.    
  41.     # try gracefully first
  42.     $null = $totalcmd.CloseMainWindow()
  43.  
  44.     Sleep 2
  45.  
  46.     # if not closed, force the process to close
  47.     if (!$totalcmd.HasExited) {
  48.         $totalcmd | Stop-Process -Force
  49.  
  50.         Sleep 5
  51.     }
  52.    
  53. }
  54.  
  55.  
  56. # copy all the files to the folder of TotalCommander
  57. Write-Host "Updating $($env:tools)\TotalCommander"
  58.  
  59. xcopy /e *.* "$($env:tools)\TotalCommander" /y
  60.  
  61. if ($totalcmd)
  62. {
  63.     # launch again
  64.     start-process "$($env:tools)\TotalCommander\TotalCMD64.exe"
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement