diff options
Diffstat (limited to 'scripts/rustdesk.bat.php')
| -rw-r--r-- | scripts/rustdesk.bat.php | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/scripts/rustdesk.bat.php b/scripts/rustdesk.bat.php new file mode 100644 index 0000000..5e60787 --- /dev/null +++ b/scripts/rustdesk.bat.php | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | rem version windows | ||
| 2 | |||
| 3 | @echo off | ||
| 4 | setlocal | ||
| 5 | |||
| 6 | net session >nul 2>&1 | ||
| 7 | if %errorlevel% neq 0 ( | ||
| 8 | echo les droits administrateur sont necessaires | ||
| 9 | powershell -Command "Start-Process '%~f0' -Verb RunAs" | ||
| 10 | exit /b | ||
| 11 | ) | ||
| 12 | |||
| 13 | set config=9JSPNV1NPNWd0ZkSwUDMjRmdUZUSvZFRsZjb5IXNBBjV1VWZOhFZrVHeIN0NSJiOikXZrJCLiIiOikGchJCLiInZu8GbvBXakJ3buUGdv1WZyJiOikXYsVmciwiIyZmLvx2bwlGZy9mLlR3btVmciojI0N3boJye | ||
| 14 | |||
| 15 | rem Architecture | ||
| 16 | if defined PROCESSOR_ARCHITEW6432 ( | ||
| 17 | set "ARCH=64" | ||
| 18 | ) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( | ||
| 19 | set "ARCH=64" | ||
| 20 | ) else ( | ||
| 21 | set "ARCH=32" | ||
| 22 | ) | ||
| 23 | echo Architecture : %ARCH% bits | ||
| 24 | |||
| 25 | rem Version Windows | ||
| 26 | for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion 2^>nul') do set "WINVER=%%a" | ||
| 27 | rem Conversion de 6.1 en 61, 6.2 en 62, etc. | ||
| 28 | for /f "tokens=1,2 delims=." %%a in ("%WINVER%") do set /a WINVER=%%a*10+%%b | ||
| 29 | echo Version Windows : %WINVER% | ||
| 30 | |||
| 31 | |||
| 32 | rem Windows 7 et anterieurs (seuil 61) | ||
| 33 | if %WINVER% LEQ 61 ( | ||
| 34 | echo Ancienne version de Windows detectee | ||
| 35 | set "URL=https://remote.ordipolo.fr/client/rustdesk-x86.exe" | ||
| 36 | set "INSTALLER=C:\Temp\rustdesk.exe" | ||
| 37 | |||
| 38 | if "%ARCH%"=="64" ( | ||
| 39 | set "INSTALL_DIR=C:\Program Files (x86)\RustDesk" | ||
| 40 | ) else ( | ||
| 41 | set "INSTALL_DIR=C:\Program Files\RustDesk" | ||
| 42 | ) | ||
| 43 | ) else ( | ||
| 44 | echo Windows 8 ou superieur | ||
| 45 | |||
| 46 | if "%ARCH%"=="64" ( | ||
| 47 | set "URL=https://remote.ordipolo.fr/client/rustdesk-x64.msi" | ||
| 48 | set "INSTALLER=C:\Temp\rustdesk.msi" | ||
| 49 | ) else ( | ||
| 50 | set "URL=https://remote.ordipolo.fr/client/rustdesk-x86.exe" | ||
| 51 | set "INSTALLER=C:\Temp\rustdesk.exe" | ||
| 52 | ) | ||
| 53 | set "INSTALL_DIR=C:\Program Files\RustDesk" | ||
| 54 | ) | ||
| 55 | echo URL : %URL% | ||
| 56 | echo Installateur : %INSTALLER% | ||
| 57 | echo Repertoire : %INSTALL_DIR% | ||
| 58 | |||
| 59 | if not exist "C:\Temp" mkdir "C:\Temp" | ||
| 60 | |||
| 61 | if exist "%INSTALL_DIR%\rustdesk.exe" ( | ||
| 62 | echo RustDesk est deja installe | ||
| 63 | "%INSTALL_DIR%\rustdesk.exe" --config "%config%" | ||
| 64 | timeout /t 2 /nobreak >nul | ||
| 65 | start "" "%INSTALL_DIR%\rustdesk.exe" | ||
| 66 | exit /b | ||
| 67 | ) | ||
| 68 | |||
| 69 | |||
| 70 | @where curl.exe >nul 2>&1 | ||
| 71 | |||
| 72 | @if %errorlevel%==0 ( | ||
| 73 | echo Telechargement de RustDesk via cURL | ||
| 74 | curl.exe -fL -z "%INSTALLER%" -o "%INSTALLER%" "%URL%" || exit /b 1 | ||
| 75 | |||
| 76 | ) else ( | ||
| 77 | if not exist "%INSTALLER%" ( | ||
| 78 | rem pas de curl dans windows 7, utiliser powershell (nécessite .NET framework 4.8) | ||
| 79 | echo Telechargement de RustDesk via PowerShell | ||
| 80 | powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([Net.SecurityProtocolType], 3072); $wc = New-Object Net.WebClient; $wc.DownloadFile('%URL%', '%INSTALLER%')" || exit /b 1 | ||
| 81 | ) else ( | ||
| 82 | echo RustDesk deja telecharge | ||
| 83 | ) | ||
| 84 | ) | ||
| 85 | |||
| 86 | |||
| 87 | echo Installation de RustDesk | ||
| 88 | if "%ARCH%"=="64" if %WINVER% GTR 61 ( | ||
| 89 | msiexec /i "%INSTALLER%" /qn INSTALLPRINTER=N | ||
| 90 | goto INSTALL_OK | ||
| 91 | ) | ||
| 92 | |||
| 93 | rem évite de mettre :WAIT_INSTALL dans un bloc if, else, etc | ||
| 94 | start "" /wait "%INSTALLER%" --silent-install | ||
| 95 | if errorlevel 1 ( | ||
| 96 | echo "erreur de l'installation de RustDesk" | ||
| 97 | exit /b 1 | ||
| 98 | ) | ||
| 99 | |||
| 100 | rem parce que start "" /wait peut ne pas avoir le comportement attendu | ||
| 101 | set /a COUNT=0 | ||
| 102 | :WAIT_INSTALL | ||
| 103 | if exist "%INSTALL_DIR%\rustdesk.exe" ( | ||
| 104 | echo installation terminee | ||
| 105 | goto INSTALL_OK | ||
| 106 | ) | ||
| 107 | set /a COUNT+=1 | ||
| 108 | if %COUNT% GEQ 60 ( | ||
| 109 | echo erreur installation non reussie apres 60s | ||
| 110 | exit /b 1 | ||
| 111 | ) | ||
| 112 | timeout /t 1 /nobreak >nul | ||
| 113 | goto WAIT_INSTALL | ||
| 114 | |||
| 115 | :INSTALL_OK | ||
| 116 | |||
| 117 | |||
| 118 | echo Installation du service | ||
| 119 | "%INSTALL_DIR%\rustdesk.exe" --install-service | ||
| 120 | timeout /t 3 /nobreak >nul | ||
| 121 | |||
| 122 | echo Application de la configuration | ||
| 123 | "%INSTALL_DIR%\rustdesk.exe" --config "%config%" | ||
| 124 | timeout /t 2 /nobreak >nul | ||
| 125 | |||
| 126 | start "" "%INSTALL_DIR%\rustdesk.exe" | ||
