forked from igoz89/dynasryrdp
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9152d5f
commit 8b00adc
Showing
1 changed file
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,46 @@ | ||
# 禁用防火墙 | ||
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False | ||
& {$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} | ||
|
||
# 定义下载和安装函数 | ||
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" | ||
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" | ||
} | ||
} | ||
} | ||
|
||
# 使用后台作业并行下载和安装 | ||
$job1 = Start-Job -ScriptBlock { | ||
Download-And-Install -url "https://dl.google.com/edgedl/chrome-remote-desktop/chromeremotedesktophost.msi" -fileName "chromeremotedesktophost.msi" | ||
} | ||
|
||
$job2 = Start-Job -ScriptBlock { | ||
Download-And-Install -url "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -fileName "chrome_installer.exe" -installArgs "/install" | ||
} | ||
|
||
# 等待所有作业完成 | ||
Wait-Job -Job $job1, $job2 | ||
|
||
# 输出作业结果 | ||
Receive-Job -Job $job1, $job2 | ||
|
||
# 清理作业 | ||
Remove-Job -Job $job1, $job2 |