-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-dia.bat
80 lines (76 loc) · 2.89 KB
/
get-dia.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
@ECHO OFF && ECHO.
:: "get-dia.bat" v2.0.0 (2021/03/02) by Tristano Ajmone
ECHO *********************************************************************************
ECHO * *
ECHO * Automatic Dia Downloader for Windows *
ECHO * *
ECHO *********************************************************************************
ECHO This script will download the correct version of Dia and unpack it to the "Dia\"
ECHO folder inside the current directory.
:: -----------------------------------------------------------------------------
SETLOCAL ENABLEDELAYEDEXPANSION
SET DiaVer=0.97
SET DiaZip=dia_0.97_win32.zip
SET DiaZipURL=https://sourceforge.net/projects/dia-installer/files/dia/0,97/!DiaZip!/download
SET DiaDir=Dia\
:: -----------------------------------------------------------------------------
:: Check if OS is Windows 10:
VER | FIND "Version 10" > NUL
IF ERRORLEVEL == 1 (
ECHO.
ECHO *** WARNING^^!^^!^^! *** This script requires Windows 10 to work because it depends on
ECHO cURL and PowerShell 5. It might not work on your machine.
ECHO.
)
:: -----------------------------------------------------------------------------
CALL :header1 "1. Download Dia %DiaVer%"
IF EXIST !DiaZip! (
ECHO The folder arealdy contains a "!DiaZip!" archive^^!
CHOICE /C:YN /T 5 /D N /M "Do you want to overwrite it?"
IF !ERRORLEVEL! EQU 2 GOTO unpackDia
ECHO Deleting old version of "!DiaZip!"...
DEL !DiaZip!
)
ECHO Fetching "!DiaZip!" via cURL from:
ECHO !DiaZipURL!
CALL :ruler2
CALL curl !DiaZipURL! -OJLf || (
CALL :error "cURL exited with error."
GOTO :abort
)
:: -----------------------------------------------------------------------------
:unpackDia
CALL :header1 "2. Unpack Dia Zip Archive via PowerShell"
IF EXIST !DiaDir! (
ECHO Deleting old "!DiaDir!" folder...
RD /S /Q !DiaDir!
)
ECHO Invoking PowerShell to unpack "!DiaZip!" to "!DiaDir!"...
CALL powershell -command "Expand-Archive !DiaZip! .\\" || (
CALL :error "An error occurred while unpacking Dia."
GOTO :abort
)
ECHO /// Finished^^! ///
EXIT /B
:: =============================================================================
:: CUSTOM FUNCTIONS
:: =============================================================================
:error
ECHO *** ERROR^^!^^!^^! *******************************************************************
ECHO %~1
ECHO ********************************************************************************
EXIT /B
:abort
ECHO /// Aborting script execution^^! ///
EXIT /B 1
:header1
CALL :ruler1
ECHO %~1
CALL :ruler1
EXIT /B
:ruler1
ECHO ================================================================================
EXIT /B
:ruler2
ECHO ................................................................................
EXIT /B