51 lines
1.6 KiB
PowerShell
51 lines
1.6 KiB
PowerShell
param([switch]$Elevated)
|
||
function Check-Admin {
|
||
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
|
||
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
|
||
}
|
||
if ((Check-Admin) -eq $false) {
|
||
if ($elevated)
|
||
{
|
||
# could not elevate, quit
|
||
}
|
||
|
||
else {
|
||
|
||
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
|
||
}
|
||
exit
|
||
}
|
||
$TempInstallDir = "c:\teamviewer_install\"
|
||
if (Test-Path $TempInstallDir) {
|
||
Remove-Item $TempInstallDir -Recurse -Force
|
||
}
|
||
else
|
||
{
|
||
Write-Host "Install Start"
|
||
}
|
||
$TeamViewerFileName = "C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
|
||
$TeamViewer64FileName = "C:\Program Files\TeamViewer\TeamViewer.exe"
|
||
|
||
|
||
function not-exist { -not (Test-Path -Path $TeamViewer64FileName) }
|
||
function not-exist { -not (Test-Path -Path $TeamViewerFileName) }
|
||
if (-not (Test-Path -Path $TeamViewerFileName)) {}
|
||
if (-not (Test-Path -Path $TeamViewer64FileName)) {
|
||
mkdir c:\teamviewer_install
|
||
$url = "https://download.teamviewer.com/download/version_15x/TeamViewer_MSI32.zip"
|
||
$output = "c:\teamviewer_install\TeamviewerHost.zip"
|
||
$tvdir = "c:\teamviewer_install"
|
||
$start_time = Get-Date
|
||
|
||
$wc = New-Object System.Net.WebClient
|
||
$wc.DownloadFile($url, $output)
|
||
Write-Host "Teamviewer Downloaded"
|
||
sleep 3
|
||
Expand-Archive -LiteralPath $output -DestinationPath $tvdir -Force
|
||
msiexec.exe /i "c:\teamviewer_install\Host\Teamviewer_Host.msi" /qn CUSTOMCONFIGID=6988pev APITOKEN=6581446-B1aEz7nIk9k92p4G7C1R ASSIGNMENTOPTIONS="--grant-easy-access"
|
||
Write-Host "Teamviewer Installed"
|
||
}
|
||
Else
|
||
{
|
||
Write-Host "TeamViewer Already Installed"
|
||
} |