Skip to content

Commit

Permalink
fix(install.bat): run in elevate cmd; detach WeaselServer process
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Feb 25, 2018
1 parent 3793e22 commit 2194d9f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 25 deletions.
45 changes: 31 additions & 14 deletions output/install.bat
Original file line number Diff line number Diff line change
@@ -1,40 +1,57 @@
@echo off

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

set CD_BACK=%CD%
cd "%~dp0"

if /i "%2" == "/register" goto register

echo stopping service from an older version.
call stop_service.bat

echo configuring preset input schemas...
WeaselDeployer.exe /install

echo administrative permissions required. detecting permissions...
net session >nul 2>&1
if not %errorlevel% == 0 (
echo elevating command prompt...
cscript sudo.js "%~nx0" %install_option% /register
exit /b
)

:register
echo registering Weasel IME to your system.
echo install_option=%install_option%

wscript check_windows_version.js
cscript check_windows_version.js
if errorlevel 2 goto win7_x64_install
if errorlevel 1 goto xp_install

:win7_install
wscript sudo.js WeaselSetup.exe %WEASEL_INSTALL_OPTION%
rem wscript sudo.js regsvr32.exe /s "%CD%\weasel.dll"
goto exit
WeaselSetup.exe %install_option%
rem regsvr32.exe /s "%CD%\weasel.dll"
goto next

:win7_x64_install
wscript sudo.js WeaselSetupx64.exe %WEASEL_INSTALL_OPTION%
rem wscript sudo.js regsvr32.exe /s "%CD%\weasel.dll"
rem wscript sudo.js regsvr32.exe /s "%CD%\weaselx64.dll"
goto exit
WeaselSetupx64.exe %install_option%
rem regsvr32.exe /s "%CD%\weasel.dll"
rem regsvr32.exe /s "%CD%\weaselx64.dll"
goto next

:xp_install
WeaselSetup.exe %WEASEL_INSTALL_OPTION%
goto exit
WeaselSetup.exe %install_option%
goto next

:exit
:next
reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" /v WeaselServer /t REG_SZ /d "%CD%\WeaselServer.exe" /f
WeaselServer.exe

:done
start WeaselServer.exe

if /i "%2" == "/register" pause
echo installed.
cd "%CD_BACK%"
1 change: 0 additions & 1 deletion output/shell.bat

This file was deleted.

37 changes: 27 additions & 10 deletions output/uninstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,46 @@

set CD_BACK=%CD%
cd "%~dp0"

if /i "%1" == "/unregister" goto unregister

echo stopping service.
call stop_service.bat

echo administrative permissions required. detecting permissions...
net session >nul 2>&1
if not %errorlevel% == 0 (
echo elevating command prompt...
cscript sudo.js "%~nx0" /unregister
exit /b
)

:unregister
echo uninstalling Weasel ime.

wscript check_windows_version.js
cscript check_windows_version.js
if errorlevel 2 goto win7_x64_uninstall
if errorlevel 1 goto xp_uninstall

:win7_uninstall
wscript sudo.js WeaselSetup.exe /u
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weasel.dll"
goto exit
WeaselSetup.exe /u
rem regsvr32.exe /s /u "%CD%\weasel.dll"
goto next

:win7_x64_uninstall
wscript sudo.js WeaselSetupx64.exe /u
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weasel.dll"
rem wscript sudo.js regsvr32.exe /s /u "%CD%\weaselx64.dll"
goto exit
WeaselSetupx64.exe /u
rem regsvr32.exe /s /u "%CD%\weasel.dll"
rem regsvr32.exe /s /u "%CD%\weaselx64.dll"
goto next

:xp_uninstall
WeaselSetup.exe /u
goto exit
goto next

:exit
:next
reg delete "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" /v WeaselServer /f

:done
if /i "%1" == "/unregister" pause
echo uninstalled.
cd "%CD_BACK%"

0 comments on commit 2194d9f

Please sign in to comment.