-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.cmd
113 lines (96 loc) · 2.5 KB
/
update.cmd
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
102
103
104
105
106
107
108
109
110
111
112
113
@echo off
setlocal EnableDelayedExpansion
set src_7z=%~1
set dest_path=%~2
set SEVENZIP=
where 7z > nul 2>&1
if not errorlevel 1 (
set SEVENZIP=7z
goto done_sevenzip
)
where 7za > nul 2>&1
if not errorlevel 1 (
set SEVENZIP=7za
goto done_sevenzip
)
for /f "tokens=3,*" %%v in ('reg query HKLM\Software\7-Zip /v Path64') do (
if exist "%%v %%w7z.exe" (
set "SEVENZIP=%%v %%w7z.exe"
goto done_sevenzip
)
if exist "%%v %%w7za.exe" (
set "SEVENZIP=%%v %%w7za.exe"
goto done_sevenzip
)
)
for /f "tokens=3,*" %%v in ('reg query HKLM\Software\7-Zip /v Path') do (
if exist "%%v %%w7z.exe" (
set "SEVENZIP=%%v %%w7z.exe"
goto done_sevenzip
)
if exist "%%v %%w7za.exe" (
set "SEVENZIP=%%v %%w7za.exe"
goto done_sevenzip
)
)
set WINRAR=
where winrar > nul 2>&1
if not errorlevel 1 (
set WINRAR=winrar
goto done_winrar
)
for /f "tokens=3,*" %%v in ('reg query HKLM\Software\WinRAR /v exe64') do (
set "WINRAR=%%v %%w"
goto done_winrar
)
for /f "tokens=3,*" %%v in ('reg query HKLM\Software\WOW6432Node\WinRAR /v exe32') do (
set "WINRAR=%%v %%w"
goto done_winrar
)
if not defined SEVENZIP (
if not defined WINRAR (
echo 7zip and WinRAR not found
pause
exit /b 1
)
)
:done_sevenzip
for /f %%f in ("%src_7z%") do set "src_path=%%~dpf"
if exist "%src_path%\Keypirinha" rmdir /Q /S "%src_path%\Keypirinha"
"%SEVENZIP%" x -o"%src_path%" "%src_7z%"
if errorlevel 1 (
echo Extracting new Keypirinha failed
pause
exit /b 1
)
goto after_unpack
:done_winrar
for /f %%f in ("%src_7z%") do set "src_path=%%~dpf"
if exist "%src_path%\Keypirinha" rmdir /Q /S "%src_path%\Keypirinha"
"%WINRAR%" x -ibck "%src_7z%" "%src_path%"
if errorlevel 1 (
echo Extracting new Keypirinha failed
pause
exit /b 1
)
goto after_unpack
:after_unpack
taskkill /IM keypirinha-x64.exe /F
taskkill /IM keypirinha-x86.exe /F
taskkill /IM keypirinha.exe /F
robocopy "%dest_path%" "%temp%\kp_bak" *.* /XD portable /XF portable.ini /MOVE
if errorlevel 4 (
echo Error removing old installation
pause
exit /b 1
)
robocopy "%src_path%\Keypirinha" "%dest_path%" *.* /E /XD portable /XF portable.ini
if errorlevel 4 (
echo Error copying new installation
pause
exit /b 1
)
rmdir /Q /S "%temp%\kp_bak"
del / Q "%src_7z%"
rmdir /Q /S "%src_path%\Keypirinha"
exit /b 0