diff --git a/windows/service-install.bat b/windows/service-install.bat index 6a66b18c..b593c02d 100755 --- a/windows/service-install.bat +++ b/windows/service-install.bat @@ -1,23 +1,21 @@ -@ECHO OFF +@ECHO OFF & SETLOCAL ENABLEEXTENSIONS -SFC 2>&1 | FIND /i "/SCANNOW" >NUL -IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE -GOTO ADMINTASKS +CD /d %~dp0 +SFC 2>&1 | FIND /i "/SCANNOW" >NUL: +IF ERRORLEVEL 1 GOTO :ELEVATE +GOTO :ADMINTASKS :ELEVATE + ECHO Elevated privileges are temporarily required, just to register or remove the dnscrypt-proxy service -CD /d %~dp0 MSHTA "javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();" EXIT :ADMINTASKS -CD /d %~dp0 +dnscrypt-proxy.exe -service install +dnscrypt-proxy.exe -service start -CMD.EXE /c "dnscrypt-proxy.exe -service install" -CMD.EXE /c "dnscrypt-proxy.exe -service start" - -ECHO "" +ECHO. SET /P _=Thank you for using dnscrypt-proxy! Hit [RETURN] to finish - EXIT diff --git a/windows/service-restart.bat b/windows/service-restart.bat index 978abaab..32e8bd24 100755 --- a/windows/service-restart.bat +++ b/windows/service-restart.bat @@ -1,23 +1,33 @@ -@ECHO OFF +@ECHO OFF & SETLOCAL ENABLEEXTENSIONS -SFC 2>&1 | FIND /i "/SCANNOW" >NUL -IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE -GOTO ADMINTASKS +CD /d %~dp0 +SFC 2>&1 | FIND /i "/SCANNOW" >NUL: +IF ERRORLEVEL 1 GOTO :ELEVATE +GOTO :ADMINTASKS :ELEVATE -ECHO Elevated privileges are temporarily required, just to register or remove the dnscrypt-proxy service -CD /d %~dp0 + +ECHO Elevated privileges are temporarily required, just to register or remove the dnscrypt-proxy service. MSHTA "javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();" EXIT :ADMINTASKS -CD /d %~dp0 +REM If DNSCrypt-Proxy is not yet running restart will fail +Tasklist /FI "IMAGENAME eq dnscrypt-proxy.exe" /NH | Find "dnscrypt-proxy.exe" >NUL: +IF ERRORLEVEL 1 GOTO :SVCSTART -CMD.EXE /c "dnscrypt-proxy.exe -service stop" -CMD.EXE /c "dnscrypt-proxy.exe -service start" +ECHO Re-Starting Service... +dnscrypt-proxy.exe -service restart +GOTO :SAYTHANKS -ECHO "" +:SVCSTART + +ECHO Starting Service... +dnscrypt-proxy.exe -service start + +:SAYTHANKS + +ECHO. SET /P _=Thank you for using dnscrypt-proxy! Hit [RETURN] to finish - EXIT diff --git a/windows/service-uninstall.bat b/windows/service-uninstall.bat index b1772783..c7b4539d 100755 --- a/windows/service-uninstall.bat +++ b/windows/service-uninstall.bat @@ -1,23 +1,21 @@ -@ECHO OFF +@ECHO OFF & SETLOCAL ENABLEEXTENSIONS -SFC 2>&1 | FIND /i "/SCANNOW" >NUL -IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE -GOTO ADMINTASKS +CD /d %~dp0 +SFC 2>&1 | FIND /i "/SCANNOW" >NUL: +IF ERRORLEVEL 1 GOTO :ELEVATE +GOTO :ADMINTASKS :ELEVATE + ECHO Elevated privileges are temporarily required, just to register or remove the dnscrypt-proxy service -CD /d %~dp0 MSHTA "javascript: var shell = new ActiveXObject('shell.application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();" EXIT :ADMINTASKS -CD /d %~dp0 +dnscrypt-proxy.exe -service stop +dnscrypt-proxy.exe -service uninstall -CMD.EXE /c ".\dnscrypt-proxy.exe -service stop" -CMD.EXE /c ".\dnscrypt-proxy.exe -service uninstall" - -ECHO "" +ECHO. SET /P _=Thank you for using dnscrypt-proxy! Hit [RETURN] to finish - EXIT