-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_clion.bat
95 lines (79 loc) · 3.89 KB
/
install_clion.bat
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
::
:: install_clion.bat
:: WSpring
::
:: Created by kimbomm on 2018. 02. 04...
:: Copyright 2017-2018 kimbomm. All rights reserved.
::
@echo off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Get admin permission...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
rem del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
call :AbsoluteDownloadCurl
::::::::::::install
title install_clion
cd %TEMP%
echo Downloading...
powershell "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $HTML=Invoke-WebRequest -Uri 'https://confluence.jetbrains.com/display/CLION/Release+notes' -UseBasicParsing; $HTML.Links.outerHTML -ireplace '\<[^\>]*\>' > %TEMP%\clion_latest.txt"
powershell "get-content %TEMP%\clion_latest.txt -ReadCount 1000 | foreach { $_ -match 'CLion' -notMatch 'EAP' -notMatch 'RC' -match 'build'} | out-file -encoding ascii %TEMP%\clion_ver.txt"
powershell "get-content %TEMP%\clion_ver.txt | sort -Descending | get-unique | out-file -encoding ascii %TEMP%\clion_ver2.txt"
powershell "get-content %TEMP%\clion_ver2.txt -ReadCount 1000 | foreach { $_.Split(' ')[1]} | out-file -encoding ascii %TEMP%\clion_ver3.txt"
::verify laster verison of CLion
if not exist "%SystemDrive%\Program Files\JetBrains" md "%SystemDrive%\Program Files\JetBrains"
cd /D "%SystemDrive%\Program Files\JetBrains\"
set /p "VER="<"%TEMP%\clion_ver3.txt"
echo %VER% is latest version of windows clion.
curlw -L "https://download.jetbrains.com/cpp/CLion-%VER%.win.zip" -o "CLion-%VER%.zip"
::#section=windows
echo Unzipping...
call :SafeRMDIR "%SystemDrive%\Program Files\JetBrains\CLion-%VER%"
powershell -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%SystemDrive%\Program Files\JetBrains\CLion-%VER%.zip', '%SystemDrive%\Program Files\JetBrains\CLion-%VER%'); }"
echo Download settings
del "%SystemDrive%\Program Files\JetBrains\CLion-%VER%.zip"
DEL "%TEMP%\clion_latest.txt"
DEL "%TEMP%\clion_ver.txt"
DEL "%TEMP%\clion_ver2.txt"
DEL "%TEMP%\clion_ver3.txt"
if not exist "%SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains" md "%SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains"
powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%SystemDrive%\ProgramData\Microsoft\Windows\Start Menu\Programs\JetBrains\JetBrains CLion %VER%.lnk');$s.TargetPath='%SystemDrive%\Program Files\JetBrains\clion-%VER%\bin\clion64.exe';$s.Save()"
powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%USERPROFILE%\Desktop\JetBrains CLion %VER%.lnk');$s.TargetPath='%SystemDrive%\Program Files\JetBrains\clion-%VER%\bin\clion64.exe';$s.Save()"
echo Finish!!
endlocal
pause
exit /b
:SafeRMDIR
IF EXIST "%~1" (
RMDIR /S /Q "%~1"
)
exit /b
::Download CURL
:GetFileSize
if exist %~1 set FILESIZE=%~z1
if not exist %~1 set FILESIZE=-1
exit /b
:AbsoluteDownloadCurl
:loop_adc1
call :GetFileSize "%SystemRoot%\System32\curlw.exe"
if %FILESIZE% neq 2070016 (
powershell "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://github.com/springkim/WSpring/releases/download/bin/curl.exe','%WINDIR%\System32\curlw.exe')"
goto :loop_adc1
)
:loop_adc2
call :GetFileSize "%SystemRoot%\System32\ca-bundle.crt"
if %FILESIZE% neq 261889 (
powershell "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://github.com/springkim/WSpring/releases/download/bin/ca-bundle.crt','%WINDIR%\System32\ca-bundle.crt')"
goto :loop_adc2
)
exit /b