Skip to content

Commit

Permalink
Minor visual update
Browse files Browse the repository at this point in the history
  • Loading branch information
neuralpain committed Feb 6, 2024
1 parent a03533e commit f02eed1
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.history
45 changes: 37 additions & 8 deletions installrar.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<# :# DO NOT REMOVE THIS LINE

:: installrar.cmd, version 0.2.3
:: installrar.cmd
:: oneclickwinrar, version 0.3.0
:: Copyright (c) 2023, neuralpain
:: Install WinRAR

@echo off
title installrar v0.2.3
mode 44,8
title installrar (v0.3.0)
:: uses PwshBatch.cmd <https://gist.github.com/neuralpain/4ca8a6c9aca4f0a1af2440f474e92d05>
setlocal EnableExtensions DisableDelayedExpansion
set ARGS=%*
Expand All @@ -19,22 +21,49 @@ exit /b
$global:ProgressPreference = "SilentlyContinue"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$Script:WINRAR_EXE = $null
$Script:FETCH_WINRAR = $false
$winrar = "winrar-x\d{2}-\d{3}\.exe"

function Invoke-Installer($file) { Write-Host "Installing..."; Start-Process $file "/s" -Wait >$null 2>&1 }
function Invoke-Installer($file) {
$x = (($file -replace('winrar-x\d{2}-')).Trim('.exe')) / 100
Write-Host "Installing WinRAR v${x}..."

try {
Start-Process $file "/s" -Wait
Write-Host "WinRAR installed successfully." -ForegroundColor Green
}
catch {
Write-Host "Installer ran into a problem." -ForegroundColor DarkRed
Write-Host "Please restart the script." -ForegroundColor Yellow
Pause; exit
}
finally { if ($Script:FETCH_WINRAR) { Remove-Item $Script:WINRAR_EXE } }
}

function Get-Installer {
$files = Get-ChildItem -Path $pwd | Where-Object { $_.Name -match '^winrar' }
foreach ($file in $files) { if ($file -match $winrar) { return $file } }
}

if ($null -eq (Get-Installer)) {
$Script:WINRAR_EXE = (Get-Installer)

if ($null -eq $Script:WINRAR_EXE) {
Write-Host "Testing connection... " -NoNewLine
if (Test-Connection www.google.com -Quiet) {
Write-Host "OK.`nDownloading WinRAR..."
Start-BitsTransfer "https://www.rarlab.com/rar/winrar-x64-623.exe" $pwd\
} else { Write-Host "No internet."; Pause; exit 1 }
Write-Host -NoNewLine "OK.`nDownloading WinRAR... "
try { Start-BitsTransfer "https://www.rarlab.com/rar/winrar-x64-623.exe" $pwd\ }
catch {
Write-Host "`nDownloader ran into a problem." -ForegroundColor DarkRed
Write-Host "Please check your internet connection." -ForegroundColor Yellow
Pause; exit
}
$Script:WINRAR_EXE = (Get-Installer)
$Script:FETCH_WINRAR = $true
Write-Host "Done."
} else { Write-Host "No internet."; Pause; exit }
}

Invoke-Installer (Get-Installer)
Invoke-Installer $Script:WINRAR_EXE
Start-Sleep -Seconds 2
exit
24 changes: 18 additions & 6 deletions licenserar.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<# :# DO NOT REMOVE THIS LINE

:: licenserar.cmd, version 0.2.1
:: licenserar.cmd
:: oneclickwinrar, version 0.3.0
:: Copyright (c) 2023, neuralpain
:: License WinRAR

@echo off
title licenserar v0.2.1
mode 44,8
title licenserar (v0.3.0)
:: uses PwshBatch.cmd <https://gist.github.com/neuralpain/4ca8a6c9aca4f0a1af2440f474e92d05>
setlocal EnableExtensions DisableDelayedExpansion
set ARGS=%*
Expand All @@ -16,7 +18,7 @@ if defined ARGS set ARGS=%ARGS:'=''%
fsutil dirty query %systemdrive% >nul
if %ERRORLEVEL% NEQ 0 (
cls & echo.
echo This script requires administrative priviledges.
echo Please grant admin priviledges.
echo Attempting to elevate...
goto UAC_Prompt
) else ( goto :begin_script )
Expand All @@ -40,7 +42,17 @@ $rarkey = "RAR registration data`r`nTechTools.net`r`nUnlimited Company License`r
$rarreg = "$env:ProgramFiles\WinRAR\rarreg.key"
$rarg32 = "${env:ProgramFiles(x86)}\WinRAR\rarreg.key"

if (Test-Path "$env:ProgramFiles\WinRAR\WinRAR.exe" -PathType Leaf) { [IO.File]::WriteAllLines($rarreg, $rarkey) }
elseif (Test-Path "${env:ProgramFiles(x86)}\WinRAR\WinRAR.exe" -PathType Leaf) { [IO.File]::WriteAllLines($rarg32, $rarkey) }
else { Write-Host "WinRAR is not installed."; Pause; exit 1 }
if (Test-Path "$env:ProgramFiles\WinRAR\WinRAR.exe" -PathType Leaf) {
[IO.File]::WriteAllLines($rarreg, $rarkey)
}
elseif (Test-Path "${env:ProgramFiles(x86)}\WinRAR\WinRAR.exe" -PathType Leaf) {
[IO.File]::WriteAllLines($rarg32, $rarkey)
}
else {
Write-Host "WinRAR is not installed." -ForegroundColor DarkRed
Pause; exit
}

Write-Host "WinRAR licensed successfully." -ForegroundColor Green
Start-Sleep -Seconds 2
exit
56 changes: 46 additions & 10 deletions oneclickrar.cmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<# :# DO NOT REMOVE THIS LINE

:: oneclickrar.cmd, version 0.2.3
:: oneclickrar.cmd
:: oneclickwinrar, version 0.3.0
:: Copyright (c) 2023, neuralpain
:: Install and license WinRAR

@echo off
title oneclickrar v0.2.3
mode 44,8
title oneclickrar (v0.3.0)
:: uses PwshBatch.cmd <https://gist.github.com/neuralpain/4ca8a6c9aca4f0a1af2440f474e92d05>
setlocal EnableExtensions DisableDelayedExpansion
set ARGS=%*
Expand All @@ -19,27 +21,61 @@ exit /b
$global:ProgressPreference = "SilentlyContinue"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$Script:WINRAR_EXE = $null
$Script:FETCH_WINRAR = $false
$rarkey = "RAR registration data`r`nTechTools.net`r`nUnlimited Company License`r`nUID=be495af2e04c51526b85`r`n64122122506b85be56d054210a35c74d3d4b85c98b58c1c03635b4`r`n931f702fd05f10d8593c60fce6cb5ffde62890079861be57638717`r`n7131ced835ed65cc743d9777f2ea71a8e32c7e593cf66794343565`r`nb41bcf56929486b8bcdac33d50ecf77399607b61cbd4c7c227f192`r`n2b3291c3cf4822a590ea57181b47bfe6cf92ddc40a7de2d2796819`r`n1781857ba6b1b67a2b15bc5f9dfb682cca338eaa5c606da560397f`r`n6c6efc340004788adcfe55aa8c331391a95957b7e7401955721377"
$winrar = "winrar-x\d{2}-\d{3}\.exe"
$rarreg = "rarreg.key"

function Write-License { if (-not(Test-Path $rarreg -PathType Leaf)) { [IO.File]::WriteAllLines($rarreg, $rarkey) } }
function Invoke-Installer($file) { Write-Host "Installing..."; Start-Process $file "/s" -Wait >$null 2>&1 }
function Invoke-Installer($file) {
$x = (($file -replace('winrar-x\d{2}-')).Trim('.exe')) / 100
Write-Host "Installing WinRAR v${x}..."

try {
Start-Process $file "/s" -Wait
Write-Host "WinRAR installed successfully." -ForegroundColor Green
}
catch {
Write-Host "Installer ran into a problem." -ForegroundColor DarkRed
Write-Host "Please restart the script." -ForegroundColor Yellow
Pause; exit
}
finally {
Remove-Item $rarreg
if ($Script:FETCH_WINRAR) { Remove-Item $Script:WINRAR_EXE }
}
}

function Write-License {
if (-not(Test-Path $rarreg -PathType Leaf)) {
[IO.File]::WriteAllLines($rarreg, $rarkey)
}
}

function Get-Installer {
$files = Get-ChildItem -Path $pwd | Where-Object { $_.Name -match '^winrar' }
foreach ($file in $files) { if ($file -match $winrar) { return $file } }
}

if ($null -eq (Get-Installer)) {
$Script:WINRAR_EXE = (Get-Installer)

if ($null -eq $Script:WINRAR_EXE) {
Write-Host "Testing connection... " -NoNewLine
if (Test-Connection www.google.com -Quiet) {
Write-Host "OK.`nDownloading WinRAR..."
Start-BitsTransfer "https://www.rarlab.com/rar/winrar-x64-623.exe" $pwd\
} else { Write-Host "No internet."; Pause; exit 1 }
Write-Host -NoNewLine "OK.`nDownloading WinRAR... "
try { Start-BitsTransfer "https://www.rarlab.com/rar/winrar-x64-623.exe" $pwd\ }
catch {
Write-Host "`nDownloader ran into a problem." -ForegroundColor DarkRed
Write-Host "Please check your internet connection." -ForegroundColor Yellow
Pause; exit
}
$Script:WINRAR_EXE = (Get-Installer)
$Script:FETCH_WINRAR = $true
Write-Host "Done."
} else { Write-Host "No internet."; Pause; exit }
}

Write-License
Invoke-Installer (Get-Installer)
Remove-Item $rarreg
Invoke-Installer $Script:WINRAR_EXE
Start-Sleep -Seconds 2
exit

0 comments on commit f02eed1

Please sign in to comment.