Skip to content

Commit

Permalink
Update setup.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
xmt3061123 authored Jun 21, 2024
1 parent 70d6d9b commit cb26cf0
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions setup.ps1
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
# 禁用防火墙
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

# 定义下载和安装函数
function Download-And-Install {
param (
[string]$url,
[string]$fileName,
[string]$installArgs = ""
)

$tempPath = Join-Path -Path $env:TEMP -ChildPath $fileName
try {
Write-Output "Downloading $url to $tempPath"
Invoke-WebRequest -Uri $url -OutFile $tempPath -ErrorAction Stop
Write-Output "Starting installation of $fileName"

if ($fileName -like "*.msi") {
# Use msiexec for .msi files
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i", $tempPath, $installArgs, "/quiet", "/norestart" -Verb RunAs -Wait -ErrorAction Stop
} else {
# Use default start process for other file types
Start-Process -FilePath $tempPath -ArgumentList $installArgs -Verb RunAs -Wait -ErrorAction Stop
}

} catch {
Write-Error "Failed to download or install ${fileName}: $_"
} finally {
if (Test-Path $tempPath) {
Remove-Item $tempPath -Force
Write-Output "${fileName} has been removed from temp"
}
}
}

# 顺序下载和安装
Download-And-Install -url "https://dl.google.com/edgedl/chrome-remote-desktop/chromeremotedesktophost.msi" -fileName "chromeremotedesktophost.msi"
#Download-And-Install -url "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -fileName "chrome_installer.exe" -installArgs "/install"
& {$P = $env:TEMP + '\chromeremotedesktophost.msi'; Invoke-WebRequest 'https://dl.google.com/edgedl/chrome-remote-desktop/chromeremotedesktophost.msi' -OutFile $P; Start-Process $P -Wait; Remove-Item $P}
& {$P = $env:TEMP + '\chrome_installer.exe'; Invoke-WebRequest 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' -OutFile $P; Start-Process -FilePath $P -Args '/install' -Verb RunAs -Wait; Remove-Item $P}

0 comments on commit cb26cf0

Please sign in to comment.