-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
41 lines (32 loc) · 1.25 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function New-Shortcut {
param (
[string]$TargetPath,
[string]$ShortcutLocation
)
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($ShortcutLocation)
$shortcut.TargetPath = $TargetPath
$shortcut.Save()
}
function Get-OfflineMaster {
$localAppData = [System.Environment]::GetFolderPath("LocalApplicationData")
$startupFolder = [System.Environment]::GetFolderPath("Startup")
$owner = "agatemosu"
$name = "OfflineMaster"
$branch = "main"
$downloadUrl = "https://codeload.github.com/$owner/$name/zip/refs/heads/$branch"
$tempFile = New-TemporaryFile
$programDirectory = Join-Path -Path $localAppData -ChildPath $name
$programEntrypoint = Join-Path -Path $programDirectory -ChildPath "$name-$branch/run.pyw"
$shortcutPath = Join-Path -Path $startupFolder -ChildPath "run.pyw.lnk"
If (-Not (Test-Path -Path $programDirectory)) {
New-Item -Path $programDirectory -ItemType Directory | Out-Null
}
Invoke-WebRequest -Uri $downloadUrl -OutFile $tempFile
$tempFile.MoveTo($tempFile.FullName + ".zip")
Expand-Archive -Path $tempFile -DestinationPath $programDirectory -Force
New-Shortcut -TargetPath $programEntrypoint -ShortcutLocation $shortcutPath
$tempFile.Delete()
Start-Process $programEntrypoint
}
Get-OfflineMaster