-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall_rust.bat
More file actions
82 lines (68 loc) · 2.08 KB
/
install_rust.bat
File metadata and controls
82 lines (68 loc) · 2.08 KB
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
@echo off
setlocal enabledelayedexpansion
echo =======================================================
echo Install Rust and Cargo
echo =======================================================
set TEMP_DIR=%TEMP%\rust_install
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
if defined PROCESSOR_ARCHITEW6432 (
set ARCH=x64
) else (
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set ARCH=x64
) else (
set ARCH=x86
)
)
echo System architecture: %ARCH%
echo Downloading rustup downloader...
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://win.rustup.rs/!ARCH!', '%TEMP_DIR%\rustup-init.exe')"
if %ERRORLEVEL% neq 0 (
echo Error while downloading rustup-init.exe
goto :error
)
echo Download successfully.
echo Installing Rust...
"%TEMP_DIR%\rustup-init.exe" -y --default-toolchain stable --no-modify-path
if %ERRORLEVEL% neq 0 (
echo Error while installing Rust.
goto :error
)
set PATH=%USERPROFILE%\.cargo\bin;%PATH%
rustc --version
if %ERRORLEVEL% neq 0 (
echo Error: Rust not installed correctly.
goto :error
)
cargo --version
if %ERRORLEVEL% neq 0 (
echo Error: Cargo not installed correctly.
goto :error
)
echo =======================================================
echo Install Rust and Cargo successfully!
echo =======================================================
echo.
echo Rust version:
rustc --version
echo.
echo Cargo version:
cargo --version
echo.
echo The path to .cargo\bin has been added to the PATH variable for the current session.
echo To use Rust and Cargo in new command windows, restart your computer or
echo or add the following path to the PATH variable manually:
echo %USERPROFILE%\.cargo\bin
echo.
echo Or enter "Y" for add in PATH envarionment:
set /p ADD_PATH=Add Rust in system PATH? (Y/N):
if /i "%ADD_PATH%"=="Y" (
setx PATH "%USERPROFILE%\.cargo\bin;%PATH%" /M
echo Path added to system PATH variable.
)
goto :eof
:error
echo =======================================================
echo Error while installing Rust и Cargo
echo =======================================================
exit /b 1