Skip to content

Commit

Permalink
separate the online downloader and make it a new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
McAlec1 committed Jan 16, 2025
1 parent 4ed6610 commit b9f3cf8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
25 changes: 17 additions & 8 deletions modules/testforwt.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
$WT = "WindowsTerminal"
$CH = "conhost"
if (Get-Process -Name $WT -ErrorAction SilentlyContinue) {
Write-Output "This script is either running in the process '$($processName)' or is open somewhere else."
Write-Output "Make sure to save any work in the process '$($processName)' and we'll close it for you."
$windowsterminal = 'WindowsTerminal'
$conhost = 'conhost'
if (Get-Process -Name $windowsterminal -ErrorAction SilentlyContinue) {
Write-Output "This script is either running in the process '$($windowsterminal)' or is open somewhere else."
Write-Output "Make sure to save any work in the process '$($windowsterminal)' and we'll close it for you."
Write-Output "Press any key to continue."
$host.UI.RawUI.ReadKey() | Out-Null
$host.UI.RawUI.ReadKey("NoEcho, IncludeKeyUp")
taskkill /IM "WindowsTerminal.exe" /F
Exit-PSHostProcess
Exit-PSSession
Exit
} elseif (Get-Process -Name $conhost -ErrorAction SilentlyContinue) {
StartMainMenu
} else {
Write-Output "An error has occured create a issue on GitHub. https://github.com/mcalec-dev/gallerydl-pwsh/issues"
Write-Output "Parsing error in testforwt.ps1"
Write-Output "Press any key to continue."
$host.UI.RawUI.ReadKey("NoEcho, IncludeKeyUp")
taskkill /IM "WindowsTerminal.exe" /F
Exit-PSHostProcess
Exit-PSSession
Exit
} else if (Get-Process -Name $CH -ErrorAction SilentlyContinue) {
RunMainMenu
}
6 changes: 3 additions & 3 deletions online.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ if exist %ProgramFiles%\PowerShell\7-preview\pwsh.exe (
:: start conhost.exe pwsh -ExecutionPolicy Bypass -File %CurrentDir%\%FileName%
:: exit
:: :bb
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe pwsh -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/run.ps1 | iex"
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe pwsh -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/online.ps1 | iex"
exit
) else if exist %ProgramFiles%\PowerShell\7\pwsh.exe (
:: tasklist /FI "IMAGENAME eq WindowsTerminal.exe" /FO CSV > %TMP%\search.log
:: FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO bb
:: start conhost.exe pwsh -ExecutionPolicy Bypass -File %CurrentDir%\%FileName%
:: exit
:: :bb
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe pwsh -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/run.ps1 | iex"
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe pwsh -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/online.ps1 | iex"
exit
) else if exist %windir%\System32\WindowsPowerShell\v1.0\powershell.exe (
:: tasklist /FI "IMAGENAME eq WindowsTerminal.exe" /FO CSV > %TMP%\search.log
:: FOR /F %%A IN (search.log) DO IF %%~zA EQU 0 GOTO bb
:: start conhost.exe powershell -ExecutionPolicy Bypass -File %CurrentDir%\%FileName%
:: exit
:: :bb
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe powershell -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/run.ps1 | iex"
taskkill /IM "WindowsTerminal.exe" /F & start conhost.exe powershell -ExecutionPolicy Bypass -Command "iwr https://git.mcalec.dev/gallerydl-pwsh/online.ps1 | iex"
exit
) else (
echo PowerShell was not found.
Expand Down
9 changes: 9 additions & 0 deletions online.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$tempFolder = "$($env:TEMP)\gdl-pwsh"
New-Item -Path $tempFolder -ItemType Directory -Force | Out-Null
New-Item -Path "$($tempFolder)\modules" -ItemType Directory -Force | Out-Null
Invoke-WebRequest -Uri "https://git.mcalec.dev/gallerydl-pwsh/modules/variables.ps1" -OutFile $tempFolder\modules\variables.ps1 | Out-Null
Invoke-WebRequest -Uri "https://git.mcalec.dev/gallerydl-pwsh/modules/testforwt.ps1" -OutFile $tempFolder\modules\testforwt.ps1 | Out-Null
Invoke-WebRequest -Uri "https://git.mcalec.dev/gallerydl-pwsh/run.ps1" -OutFile $tempFolder\run.ps1
Import-Module -Name $tempFolder\variables.ps1
Import-Module -Name $tempFolder\testforwt.ps1
Import-Module -Name $tempFolder\run.ps1
9 changes: 3 additions & 6 deletions run.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
$tempFolder = "$($env:TEMP)\gdl-pwsh"
New-Item -Path $tempFolder -ItemType Directory -Force | Out-Null | Clear-Host
Invoke-WebRequest -Uri "https://git.mcalec.dev/gallerydl-pwsh/modules/testforwt.ps1" -OutFile $tempFolder\testforwt.ps1 | Out-Null | Clear-Host
Invoke-WebRequest -Uri "https://git.mcalec.dev/gallerydl-pwsh/modules/variables.ps1" -OutFile $tempFolder\variables.ps1 | Out-Null | Clear-Host
Import-Module -Name $tempFolder\testforwt.ps1
Import-Module -Name $tempFolder\variables.ps1 | Clear-Host
Import-Module -Name .\modules\variables.ps1
Import-Module -Name .\modules\testforwt.ps1
Pause
function DownloadAll {
Clear-Host
$host.UI.RawUI.WindowTitle = "Starting All Downloads"
Expand Down

0 comments on commit b9f3cf8

Please sign in to comment.