summaryrefslogtreecommitdiff
path: root/scripts/rustdesk.bat
blob: e6e6ae428aac4df1b86d7e574c6877afa4e8d139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
rem version windows

@echo off
setlocal

net session >nul 2>&1
if %errorlevel% neq 0 (
    echo les droits administrateur sont necessaires
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

set config=9JSPNV1NPNWd0ZkSwUDMjRmdUZUSvZFRsZjb5IXNBBjV1VWZOhFZrVHeIN0NSJiOikXZrJCLiIiOikGchJCLiInZu8GbvBXakJ3buUGdv1WZyJiOikXYsVmciwiIyZmLvx2bwlGZy9mLlR3btVmciojI0N3boJye

if defined PROCESSOR_ARCHITEW6432 (
    set "ARCH=64"
) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    set "ARCH=64"
) else (
    set "ARCH=32"
)
if "%ARCH%"=="64" (
    set "URL=https://remote.ordipolo.fr/scripts/rustdesk-x64.msi"
    set "INSTALLER=C:\Temp\rustdesk.msi"
) else (
    set "URL=https://remote.ordipolo.fr/scripts/rustdesk-x86.exe"
    set "INSTALLER=C:\Temp\rustdesk.exe"
)
echo Architecture : %ARCH% bits
echo URL : %URL%
echo Installateur : %INSTALLER%

if not exist "C:\Temp" mkdir "C:\Temp"

if exist "C:\Program Files\RustDesk\rustdesk.exe" (
    echo RustDesk est deja installe
    "C:\Program Files\RustDesk\rustdesk.exe" --config "%config%"
    timeout /t 2 /nobreak >nul
    start "" "C:\Program Files\RustDesk\rustdesk.exe"
    exit /b
)


@where curl.exe >nul 2>&1

@if %errorlevel%==0 (
    echo Telechargement de RustDesk via cURL
    curl.exe -fL -z "%INSTALLER%" -o "%INSTALLER%" "%URL%" || exit /b 1

) else (
    if not exist "%INSTALLER%" (
        echo Telechargement de RustDesk via PowerShell
        powershell -NoProfile -ExecutionPolicy Bypass -Command ^
            "$web_client = New-Object Net.WebClient; $web_client.DownloadFile('%URL%', '%INSTALLER%')" ^
            || exit /b 1
    ) else (
        echo RustDesk deja telecharge
    )
)


echo Installation de RustDesk
if "%ARCH%"=="64" (
    msiexec /i "%INSTALLER%" /qn INSTALLPRINTER=N
    goto INSTALL_OK
)

rem évite de mettre :WAIT_INSTALL dans un bloc if, else, etc
start "" /wait "%INSTALLER%" --silent-install
if errorlevel 1 (
    echo "erreur de l'installation de RustDesk"
    exit /b 1
)

rem parce que start "" /wait peut ne pas avoir le comportement attendu
set /a COUNT=0
:WAIT_INSTALL
if exist "C:\Program Files\RustDesk\rustdesk.exe" (
    echo installation terminee
    goto INSTALL_OK
)
set /a COUNT+=1
if %COUNT% GEQ 60 (
    echo erreur installation non reussie apres 60s
    exit /b 1
)
timeout /t 1 /nobreak >nul
goto WAIT_INSTALL

:INSTALL_OK


echo Installation du service
"C:\Program Files\RustDesk\rustdesk.exe" --install-service
timeout /t 3 /nobreak >nul

echo Application de la configuration
"C:\Program Files\RustDesk\rustdesk.exe" --config "%config%"
timeout /t 2 /nobreak >nul

start "" "C:\Program Files\RustDesk\rustdesk.exe"