Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 55 additions & 43 deletions miiShop_Install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ function get-latestmiiShop ([String] $question,[String] $installType)
{
Write-Output $question
# Download Engarak/MiiShop release from github
$repo = "Engarak/MiiShop"
if($installType.ToUpper() -eq 'UPGRADE')
{
$file = "miiShop_upgrade-0_2_x-0_2_7.zip"
$uoriDir = Get-Folder -displayMesage 'Where are the .cia files located?'
$repo = 'Engarak/MiiShop'
If ($installType.ToUpper() -eq 'UPGRADE')
{
$file = 'miiShop_upgrade-0_2_x-0_2_7.zip'
$uoriDir = Get-Folder -displayMesage $question
}
else
Else
{
$file = "miiShop_install-0_2_7.zip"
$uoriDir = Get-Folder -displayMesage 'Where is the miiShop.ps1 file located?'
$file = 'miiShop_install-0_2_7.zip'
$uoriDir = Get-Folder -displayMesage $question
}

$releases = "https://api.github.com/repos/$repo/releases"
Expand All @@ -28,74 +28,86 @@ function get-latestmiiShop ([String] $question,[String] $installType)

Write-Output 'Dowloading latest release'

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $download -Out $zip

Write-Output 'Extracting release files'
Write-Output 'Upgrading/Installing...'
Expand-Archive -path $zip -DestinationPath $uoriDir -Force

# Cleaning up target dir
Remove-Item $name -Recurse -Force -ErrorAction SilentlyContinue

# Moving from temp dir to target dir
Write-Output 'Upgrading/installing...'
$folder = $zip.Replace('.zip','')
Get-ChildItem -Path $folder -Recurse | Move-Item -Destination $uoriDir -Force
Remove-Item $name -Recurse -Force -ErrorAction SilentlyContinue

# Removing temp files
Remove-Item $zip -Force
Remove-Item $folder -Recurse -Force
$filePath="$uoriDir\start.bat"
cd $uoriDir

#$file = Get-ChildItem "$uoriDir\database\settings.csv" #for future upgrades force the settings file to get updated to force a rebuild
#$file.LastWriteTime = Get-Date
Write-Output 'Upgrade/install completed, launching miiShop'
Write-Output 'Upgrade/Install completed, launching miiShop'
$filePath = "$uoriDir\start.bat"

Stop-Transcript

Invoke-Expression $filePath
}

Function Get-Folder ([string]$displayMesage)
{
$initialDirectory=$env:HOMEDRIVE
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
Add-Type -AssemblyName System.Windows.Forms | Out-Null

$initialDirectory = $env:HOMEDRIVE
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.Description = $displayMesage
$foldername.rootfolder = "MyComputer"

if($foldername.ShowDialog() -eq "OK")
$foldername.rootfolder = 'MyComputer'

$ButtonType = [System.Windows.Forms.MessageBoxButtons]::RetryCancel
$MessageIcon = [System.Windows.Forms.MessageBoxIcon]::Error
$MessageBody = 'You must select a folder'
$MessageTitle = 'Error'

Do
{
$folder += $foldername.SelectedPath
}
return $folder
If($foldername.ShowDialog() -eq 'OK')
{
return $foldername.SelectedPath
}
Else
{
$result = [System.Windows.Forms.MessageBox]::Show($MessageBody, $MessageTitle, $ButtonType, $MessageIcon)

If ($result -eq 'Cancel')
{
Exit 1
}
}
} While ($true)
}

#get a start date, formatted for files
$dateFormat = 'M-d-y-hh_mm_ss'
$date=(get-date).ToString($dateFormat)
$date = (get-date).ToString($dateFormat)

#Start Transcript logging for what the window says
Start-Transcript -Path ('{0}\logs\MiiShopInstall_{1}.log' -f $PSScriptRoot, $date)
Start-Transcript -Path ('{0}\logs\MiiShopInstall_{1}.log' -f $PSScriptRoot, $date)

$title = "Install or Upgrade"
$message = "Is this an Install or Upgrade?"
$title = 'Install or Upgrade'
$message = 'Is this an Install or Upgrade?'

$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Upgrade", "Upgrade"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&Install", "Install"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Upgrade", 'Upgrade'
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&Install", 'Install'

$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

$result = $host.ui.PromptForChoice($title, $message, $Options, 0)

Switch ($result)
{
0 {
get-latestmiiShop -question 'Where is the miiShop.ps1 file located?'
}
1 {
get-latestmiiShop -question 'Where are your 3DS games (.cia files) located?'
}

}
{
0 {
get-latestmiiShop -question 'Where is the miiShop.ps1 file located?'
}

1 {
get-latestmiiShop -question 'Where are your 3DS games (.cia files) located?'
}
}

Stop-Transcript
# SIG # Begin signature block
Expand Down