Skip to content

Commit 2194d9f

Browse files
committed
fix(install.bat): run in elevate cmd; detach WeaselServer process
1 parent 3793e22 commit 2194d9f

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed

output/install.bat

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,57 @@
11
@echo off
22

33
rem argument 1: [ /s | /t ] register ime as zh_CN | zh_TW keyboard layout
4-
set WEASEL_INSTALL_OPTION=/s
5-
if /i "%1" == "/t" set WEASEL_INSTALL_OPTION=/t
4+
set install_option=/s
5+
if /i "%1" == "/t" set install_option=/t
66

77
set CD_BACK=%CD%
88
cd "%~dp0"
99

10+
if /i "%2" == "/register" goto register
11+
1012
echo stopping service from an older version.
1113
call stop_service.bat
1214

1315
echo configuring preset input schemas...
1416
WeaselDeployer.exe /install
1517

18+
echo administrative permissions required. detecting permissions...
19+
net session >nul 2>&1
20+
if not %errorlevel% == 0 (
21+
echo elevating command prompt...
22+
cscript sudo.js "%~nx0" %install_option% /register
23+
exit /b
24+
)
25+
26+
:register
1627
echo registering Weasel IME to your system.
28+
echo install_option=%install_option%
1729

18-
wscript check_windows_version.js
30+
cscript check_windows_version.js
1931
if errorlevel 2 goto win7_x64_install
2032
if errorlevel 1 goto xp_install
2133

2234
:win7_install
23-
wscript sudo.js WeaselSetup.exe %WEASEL_INSTALL_OPTION%
24-
rem wscript sudo.js regsvr32.exe /s "%CD%\weasel.dll"
25-
goto exit
35+
WeaselSetup.exe %install_option%
36+
rem regsvr32.exe /s "%CD%\weasel.dll"
37+
goto next
2638

2739
:win7_x64_install
28-
wscript sudo.js WeaselSetupx64.exe %WEASEL_INSTALL_OPTION%
29-
rem wscript sudo.js regsvr32.exe /s "%CD%\weasel.dll"
30-
rem wscript sudo.js regsvr32.exe /s "%CD%\weaselx64.dll"
31-
goto exit
40+
WeaselSetupx64.exe %install_option%
41+
rem regsvr32.exe /s "%CD%\weasel.dll"
42+
rem regsvr32.exe /s "%CD%\weaselx64.dll"
43+
goto next
3244

3345
:xp_install
34-
WeaselSetup.exe %WEASEL_INSTALL_OPTION%
35-
goto exit
46+
WeaselSetup.exe %install_option%
47+
goto next
3648

37-
:exit
49+
:next
3850
reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" /v WeaselServer /t REG_SZ /d "%CD%\WeaselServer.exe" /f
39-
WeaselServer.exe
51+
52+
:done
53+
start WeaselServer.exe
54+
55+
if /i "%2" == "/register" pause
56+
echo installed.
4057
cd "%CD_BACK%"

output/shell.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

output/uninstall.bat

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,46 @@
22

33
set CD_BACK=%CD%
44
cd "%~dp0"
5+
6+
if /i "%1" == "/unregister" goto unregister
7+
8+
echo stopping service.
59
call stop_service.bat
610

11+
echo administrative permissions required. detecting permissions...
12+
net session >nul 2>&1
13+
if not %errorlevel% == 0 (
14+
echo elevating command prompt...
15+
cscript sudo.js "%~nx0" /unregister
16+
exit /b
17+
)
18+
19+
:unregister
720
echo uninstalling Weasel ime.
821

9-
wscript check_windows_version.js
22+
cscript check_windows_version.js
1023
if errorlevel 2 goto win7_x64_uninstall
1124
if errorlevel 1 goto xp_uninstall
1225

1326
:win7_uninstall
14-
wscript sudo.js WeaselSetup.exe /u
15-
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weasel.dll"
16-
goto exit
27+
WeaselSetup.exe /u
28+
rem regsvr32.exe /s /u "%CD%\weasel.dll"
29+
goto next
1730

1831
:win7_x64_uninstall
19-
wscript sudo.js WeaselSetupx64.exe /u
20-
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weasel.dll"
21-
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weaselx64.dll"
22-
goto exit
32+
WeaselSetupx64.exe /u
33+
rem regsvr32.exe /s /u "%CD%\weasel.dll"
34+
rem regsvr32.exe /s /u "%CD%\weaselx64.dll"
35+
goto next
2336

2437
:xp_uninstall
2538
WeaselSetup.exe /u
26-
goto exit
39+
goto next
2740

28-
:exit
41+
:next
2942
reg delete "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" /v WeaselServer /f
43+
44+
:done
45+
if /i "%1" == "/unregister" pause
46+
echo uninstalled.
3047
cd "%CD_BACK%"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy