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
70d6d9b
commit cb26cf0
Showing
1 changed file
with
2 additions
and
37 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,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} |