Ярлык
parent
33ed90b85c
commit
619be5a6b0
154
RustInstall.ps1
154
RustInstall.ps1
|
|
@ -1,4 +1,4 @@
|
|||
$ErrorActionPreference= 'silentlycontinue'
|
||||
$ErrorActionPreference = 'silentlycontinue'
|
||||
|
||||
# Формируем пароль из зашифрованных частей
|
||||
$p1 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("cDk4"))
|
||||
|
|
@ -7,7 +7,7 @@ $p3 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(
|
|||
$rustdesk_pw = $p1 + $p2 + $p3
|
||||
|
||||
# Get your config string from your Web portal and Fill Below
|
||||
$rustdesk_cfg="0nI1JnL09GclRWL0lmL0NXdy9yL6MHc0RHaiojIpBXYiwiI9gjYwBjbXVERFRXZiNEVYBjRGdHUZhUUvBVRx52dWlmenlTY6t0U1IlMLhlI6ISeltmIsISdy5CdvBXZk1Cdp5CdzVnciojI5FGblJnIsISdy5CdvBXZk1Cdp5CdzVnciojI0N3boJye"
|
||||
$rustdesk_cfg = "0nI1JnL09GclRWL0lmL0NXdy9yL6MHc0RHaiojIpBXYiwiI9gjYwBjbXVERFRXZiNEVYBjRGdHUZhUUvBVRx52dWlmenlTY6t0U1IlMLhlI6ISeltmIsISdy5CdvBXZk1Cdp5CdzVnciojI5FGblJnIsISdy5CdvBXZk1Cdp5CdzVnciojI0N3boJye"
|
||||
|
||||
################################### Please Do Not Edit Below This Line #########################################
|
||||
|
||||
|
|
@ -31,72 +31,66 @@ echo "RustDesk $RDLATEST is the latest version."
|
|||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
|
||||
|
||||
# Skips to inputting the configuration if the latest version of RustDesk is already installed.
|
||||
if($rdver -eq "$RDLATEST") {
|
||||
echo "RustDesk $rdver is already installed."
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
echo "Inputting configuration now."
|
||||
.\rustdesk.exe --config $rustdesk_cfg
|
||||
.\rustdesk.exe --password $rustdesk_pw
|
||||
if ($rdver -eq "$RDLATEST") {
|
||||
echo "RustDesk $rdver is already installed."
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
echo "Inputting configuration now."
|
||||
.\rustdesk.exe --config $rustdesk_cfg
|
||||
.\rustdesk.exe --password $rustdesk_pw
|
||||
|
||||
# Р"обавляем параметры РІ конфигурационные файлы
|
||||
$configPath = "$env:USERPROFILE\AppData\Roaming\RustDesk\config"
|
||||
$config2Path = "$configPath\RustDesk2.toml"
|
||||
$configLocalPath = "$configPath\RustDesk_local.toml"
|
||||
# Добавляем параметры в конфигурационные файлы
|
||||
$configPath = "$env:USERPROFILE\AppData\Roaming\RustDesk\config"
|
||||
$config2Path = "$configPath\RustDesk2.toml"
|
||||
$configLocalPath = "$configPath\RustDesk_local.toml"
|
||||
|
||||
# Создаем директорию config если она не существует
|
||||
if (!(Test-Path $configPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $configPath
|
||||
}
|
||||
|
||||
# Р"обавляем параметр РІ RustDesk2.toml
|
||||
if (!(Test-Path $config2Path)) {
|
||||
"[options]`nallow-remote-config-modification = 'Y'" | Out-File -FilePath $config2Path -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $config2Path
|
||||
if (!($content -match "allow-remote-config-modification")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`nallow-remote-config-modification = 'Y'"
|
||||
} else {
|
||||
$content += "`n[options]`nallow-remote-config-modification = 'Y'"
|
||||
}
|
||||
$content | Out-File -FilePath $config2Path -Encoding utf8
|
||||
if (!(Test-Path $configPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $configPath
|
||||
}
|
||||
}
|
||||
|
||||
# Р"обавляем параметр РІ RustDesk_local.toml
|
||||
if (!(Test-Path $configLocalPath)) {
|
||||
"[options]`ntheme = 'dark'" | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $configLocalPath
|
||||
if (!($content -match "theme")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`ntheme = 'dark'"
|
||||
} else {
|
||||
$content += "`n[options]`ntheme = 'dark'"
|
||||
if (!(Test-Path $config2Path)) {
|
||||
"[options]`nallow-remote-config-modification = 'Y'" | Out-File -FilePath $config2Path -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $config2Path
|
||||
if (!($content -match "allow-remote-config-modification")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`nallow-remote-config-modification = 'Y'"
|
||||
} else {
|
||||
$content += "`n[options]`nallow-remote-config-modification = 'Y'"
|
||||
}
|
||||
$content | Out-File -FilePath $config2Path -Encoding utf8
|
||||
}
|
||||
$content | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
|
||||
echo "All done! Please double check the Network settings tab in RustDesk."
|
||||
echo ""
|
||||
echo "..............................................."
|
||||
# Show the value of the ID Variable
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
if (!(Test-Path $configLocalPath)) {
|
||||
"[options]`ntheme = 'dark'" | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $configLocalPath
|
||||
if (!($content -match "theme")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`ntheme = 'dark'"
|
||||
} else {
|
||||
$content += "`n[options]`ntheme = 'dark'"
|
||||
}
|
||||
$content | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
# Show the value of the Password Variable
|
||||
echo "Password: $rustdesk_pw"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Press Enter to open RustDesk."
|
||||
pause
|
||||
.\rustdesk.exe
|
||||
exit
|
||||
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
|
||||
echo "All done! Please double check the Network settings tab in RustDesk."
|
||||
echo ""
|
||||
echo "..............................................."
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
echo "Password: $rustdesk_pw"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Press Enter to open RustDesk."
|
||||
pause
|
||||
.\rustdesk.exe
|
||||
exit
|
||||
}
|
||||
|
||||
if (!(Test-Path C:\ProgramData\RustDesk)) {
|
||||
New-Item -ItemType Directory -Force -Path C:\ProgramData\RustDesk > null
|
||||
New-Item -ItemType Directory -Force -Path C:\ProgramData\RustDesk > null
|
||||
}
|
||||
|
||||
cd C:\ProgramData\RustDesk
|
||||
|
|
@ -109,26 +103,22 @@ Start-Sleep -Seconds 10
|
|||
$ServiceName = 'rustdesk'
|
||||
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($arrService -eq $null)
|
||||
{
|
||||
if ($arrService -eq $null) {
|
||||
echo "Installing service."
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
Start-Process .\rustdesk.exe --install-service -wait -Verbose
|
||||
Start-Sleep -Seconds 20
|
||||
}
|
||||
|
||||
while ($arrService.Status -ne 'Running')
|
||||
{
|
||||
while ($arrService.Status -ne 'Running') {
|
||||
Start-Service $ServiceName
|
||||
Start-Sleep -seconds 5
|
||||
$arrService.Refresh()
|
||||
}
|
||||
|
||||
# Waits for installation to complete before proceeding.
|
||||
echo "Please wait a few seconds."
|
||||
Start-Sleep -Seconds 10
|
||||
|
||||
# Удаляем временные файлы после установки
|
||||
Remove-Item -Path "C:\ProgramData\RustDesk\rustdesk.exe" -Force
|
||||
echo "Temporary installation files have been cleaned up."
|
||||
|
||||
|
|
@ -137,17 +127,35 @@ echo "Inputting configuration now."
|
|||
.\rustdesk.exe --config $rustdesk_cfg
|
||||
.\rustdesk.exe --password $rustdesk_pw
|
||||
|
||||
# Р"обавляем параметры РІ конфигурационные файлы
|
||||
# Удаляем ярлык с общего рабочего стола, если он был создан
|
||||
$publicDesktop = "C:\Users\Public\Desktop\RustDesk.lnk"
|
||||
if (Test-Path $publicDesktop) {
|
||||
Remove-Item -Path $publicDesktop -Force
|
||||
echo "Removed RustDesk shortcut from Public Desktop."
|
||||
}
|
||||
|
||||
# Создаем папку RustDesk в меню Пуск и перемещаем туда ярлык
|
||||
$startMenuPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Critical Fixes\RustDesk"
|
||||
if (!(Test-Path $startMenuPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $startMenuPath
|
||||
}
|
||||
|
||||
$shortcutPath = "$startMenuPath\RustDesk.lnk"
|
||||
$shell = New-Object -ComObject WScript.Shell
|
||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||
$shortcut.TargetPath = "$env:ProgramFiles\RustDesk\rustdesk.exe"
|
||||
$shortcut.Save()
|
||||
echo "Created RustDesk shortcut in Start Menu under Critical Fixes\RustDesk."
|
||||
|
||||
# Добавляем параметры в конфигурационные файлы
|
||||
$configPath = "$env:USERPROFILE\AppData\Roaming\RustDesk\config"
|
||||
$config2Path = "$configPath\RustDesk2.toml"
|
||||
$configLocalPath = "$configPath\RustDesk_local.toml"
|
||||
|
||||
# Создаем директорию config если она не существует
|
||||
if (!(Test-Path $configPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $configPath
|
||||
}
|
||||
|
||||
# Р"обавляем параметр РІ RustDesk2.toml
|
||||
if (!(Test-Path $config2Path)) {
|
||||
"[options]`nallow-remote-config-modification = 'Y'" | Out-File -FilePath $config2Path -Encoding utf8
|
||||
} else {
|
||||
|
|
@ -162,7 +170,6 @@ if (!(Test-Path $config2Path)) {
|
|||
}
|
||||
}
|
||||
|
||||
# Р"обавляем параметр РІ RustDesk_local.toml
|
||||
if (!(Test-Path $configLocalPath)) {
|
||||
"[options]`ntheme = 'dark'" | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
} else {
|
||||
|
|
@ -181,28 +188,21 @@ $rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
|
|||
echo "All done! Please double check the Network settings tab in RustDesk."
|
||||
echo ""
|
||||
echo "..............................................."
|
||||
# Show the value of the ID Variable
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
|
||||
# Show the value of the Password Variable
|
||||
$RustID = $rustdesk_id
|
||||
$ComputerName = $env:COMPUTERNAME
|
||||
$InstallTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
# URL сервера
|
||||
$ServerURL = "http://rust.it-depot.ru:6661/api/install"
|
||||
|
||||
# Формируем JSON
|
||||
$Body = @{
|
||||
"rust_id" = $RustID
|
||||
"rust_id" = $RustID
|
||||
"computer_name" = $ComputerName
|
||||
"install_time" = $InstallTime
|
||||
"install_time" = $InstallTime
|
||||
} | ConvertTo-Json -Compress
|
||||
|
||||
# Отправляем POST-запрос
|
||||
Invoke-RestMethod -Uri $ServerURL -Method Post -Body $Body -ContentType "application/json"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Press Enter to open RustDesk."
|
||||
pause
|
||||
.\rustdesk.exe
|
||||
.\rustdesk.exe
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
$ErrorActionPreference= 'silentlycontinue'
|
||||
|
||||
# Формируем пароль из зашифрованных частей
|
||||
$p1 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("cDk4"))
|
||||
$p2 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("Nng="))
|
||||
$p3 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("Yjc4"))
|
||||
$rustdesk_pw = $p1 + $p2 + $p3
|
||||
|
||||
# Get your config string from your Web portal and Fill Below
|
||||
$rustdesk_cfg="0nI1JnL09GclRWL0lmL0NXdy9yL6MHc0RHaiojIpBXYiwiI9gjYwBjbXVERFRXZiNEVYBjRGdHUZhUUvBVRx52dWlmenlTY6t0U1IlMLhlI6ISeltmIsISdy5CdvBXZk1Cdp5CdzVnciojI5FGblJnIsISdy5CdvBXZk1Cdp5CdzVnciojI0N3boJye"
|
||||
|
||||
################################### Please Do Not Edit Below This Line #########################################
|
||||
|
||||
# Запуск с правами администратора
|
||||
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
|
||||
Exit;
|
||||
}
|
||||
}
|
||||
|
||||
# Получаем путь к установщику
|
||||
$installerPath = Join-Path $PSScriptRoot "rustdesk.exe"
|
||||
|
||||
# Проверяем наличие установщика
|
||||
if (!(Test-Path $installerPath)) {
|
||||
echo "Ошибка: rustdesk.exe не найден в директории скрипта"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Проверяем, установлен ли уже RustDesk
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\" -ErrorAction SilentlyContinue).Version)
|
||||
|
||||
if($rdver) {
|
||||
echo "RustDesk $rdver уже установлен"
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
echo "Применяем конфигурацию..."
|
||||
.\rustdesk.exe --config $rustdesk_cfg
|
||||
.\rustdesk.exe --password $rustdesk_pw
|
||||
|
||||
# Добавляем параметры в конфиг файлы
|
||||
$configPath = "$env:USERPROFILE\AppData\Roaming\RustDesk\config"
|
||||
$config2Path = "$configPath\RustDesk2.toml"
|
||||
$configLocalPath = "$configPath\RustDesk_local.toml"
|
||||
|
||||
if (!(Test-Path $configPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $configPath
|
||||
}
|
||||
|
||||
if (!(Test-Path $config2Path)) {
|
||||
"[options]`nallow-remote-config-modification = 'Y'" | Out-File -FilePath $config2Path -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $config2Path
|
||||
if (!($content -match "allow-remote-config-modification")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`nallow-remote-config-modification = 'Y'"
|
||||
} else {
|
||||
$content += "`n[options]`nallow-remote-config-modification = 'Y'"
|
||||
}
|
||||
$content | Out-File -FilePath $config2Path -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
if (!(Test-Path $configLocalPath)) {
|
||||
"[options]`ntheme = 'dark'" | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $configLocalPath
|
||||
if (!($content -match "theme")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`ntheme = 'dark'"
|
||||
} else {
|
||||
$content += "`n[options]`ntheme = 'dark'"
|
||||
}
|
||||
$content | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
|
||||
echo "Конфигурация завершена! Проверьте сетевые настройки в RustDesk."
|
||||
echo ""
|
||||
echo "..............................................."
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
echo "Пароль: $rustdesk_pw"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Нажмите Enter для запуска RustDesk."
|
||||
pause
|
||||
.\rustdesk.exe
|
||||
exit
|
||||
}
|
||||
|
||||
# Создаем директорию ProgramData если нужно
|
||||
if (!(Test-Path C:\ProgramData\RustDesk)) {
|
||||
New-Item -ItemType Directory -Force -Path C:\ProgramData\RustDesk > null
|
||||
}
|
||||
|
||||
# Копируем установщик
|
||||
Copy-Item $installerPath C:\ProgramData\RustDesk\rustdesk.exe
|
||||
cd C:\ProgramData\RustDesk
|
||||
|
||||
echo "Установка RustDesk..."
|
||||
Start-Process .\rustdesk.exe -ArgumentList "--silent-install" -Wait
|
||||
Start-Sleep -Seconds 15
|
||||
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
|
||||
# Модифицированная установка сервиса для Windows 7
|
||||
echo "Установка и запуск сервиса..."
|
||||
Start-Process .\rustdesk.exe -ArgumentList "--install-service" -Wait -NoNewWindow
|
||||
Start-Sleep -Seconds 10
|
||||
|
||||
# Пробуем запустить сервис несколько раз
|
||||
$maxAttempts = 3
|
||||
$attempt = 0
|
||||
$ServiceName = 'rustdesk'
|
||||
|
||||
do {
|
||||
$attempt++
|
||||
echo "Попытка запуска сервиса $attempt из $maxAttempts"
|
||||
|
||||
Start-Process .\rustdesk.exe -ArgumentList "--start-service" -Wait -NoNewWindow
|
||||
Start-Sleep -Seconds 10
|
||||
|
||||
$service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
if ($service -and $service.Status -eq 'Running') {
|
||||
echo "Сервис успешно запущен"
|
||||
break
|
||||
}
|
||||
|
||||
Start-Sleep -Seconds 5
|
||||
} while ($attempt -lt $maxAttempts)
|
||||
|
||||
echo "Очистка временных файлов..."
|
||||
Remove-Item -Path "C:\ProgramData\RustDesk\rustdesk.exe" -Force
|
||||
|
||||
echo "Применение конфигурации..."
|
||||
.\rustdesk.exe --config $rustdesk_cfg
|
||||
.\rustdesk.exe --password $rustdesk_pw
|
||||
|
||||
# Добавляем параметры в конфиг файлы
|
||||
$configPath = "$env:USERPROFILE\AppData\Roaming\RustDesk\config"
|
||||
$config2Path = "$configPath\RustDesk2.toml"
|
||||
$configLocalPath = "$configPath\RustDesk_local.toml"
|
||||
|
||||
if (!(Test-Path $configPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $configPath
|
||||
}
|
||||
|
||||
if (!(Test-Path $config2Path)) {
|
||||
"[options]`nallow-remote-config-modification = 'Y'" | Out-File -FilePath $config2Path -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $config2Path
|
||||
if (!($content -match "allow-remote-config-modification")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`nallow-remote-config-modification = 'Y'"
|
||||
} else {
|
||||
$content += "`n[options]`nallow-remote-config-modification = 'Y'"
|
||||
}
|
||||
$content | Out-File -FilePath $config2Path -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
if (!(Test-Path $configLocalPath)) {
|
||||
"[options]`ntheme = 'dark'" | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
} else {
|
||||
$content = Get-Content $configLocalPath
|
||||
if (!($content -match "theme")) {
|
||||
if ($content -match "\[options\]") {
|
||||
$content = $content -replace "\[options\]", "[options]`ntheme = 'dark'"
|
||||
} else {
|
||||
$content += "`n[options]`ntheme = 'dark'"
|
||||
}
|
||||
$content | Out-File -FilePath $configLocalPath -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
$rustdesk_id = .\rustdesk.exe --get-id | Write-Output -OutVariable rustdesk_id
|
||||
echo "Установка завершена! Проверьте сетевые настройки в RustDesk."
|
||||
echo ""
|
||||
echo "..............................................."
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
|
||||
# Отправка данных об установке
|
||||
$RustID = $rustdesk_id
|
||||
$ComputerName = $env:COMPUTERNAME
|
||||
$InstallTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
# URL сервера
|
||||
$ServerURL = "http://rust.it-depot.ru:6661/api/install"
|
||||
|
||||
# Формируем JSON
|
||||
$Body = @{
|
||||
"rust_id" = $RustID
|
||||
"computer_name" = $ComputerName
|
||||
"install_time" = $InstallTime
|
||||
} | ConvertTo-Json -Compress
|
||||
|
||||
# Отправляем POST-запрос
|
||||
Invoke-RestMethod -Uri $ServerURL -Method Post -Body $Body -ContentType "application/json"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Нажмите Enter для запуска RustDesk."
|
||||
pause
|
||||
.\rustdesk.exe
|
||||
Binary file not shown.
Loading…
Reference in New Issue