File: enable-brlapi.bat

package info (click to toggle)
brltty 6.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,776 kB
  • sloc: ansic: 150,447; java: 13,484; sh: 9,667; xml: 5,702; tcl: 2,634; makefile: 2,328; awk: 713; lisp: 366; python: 321; ml: 301
file content (47 lines) | stat: -rwxr-xr-x 1,206 bytes parent folder | download | duplicates (4)
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
@echo off

setlocal EnableDelayedExpansion
set programDirectory=%~dp0
call "%programDirectory%setvars-brlapi"

set serviceState=
for /F "usebackq tokens=1,4" %%A in (
   `sc query "%serviceName%"`
) do (
   if "%%A" == "STATE" (
      set serviceState=%%B
      break
   )
)

if "%serviceState%" == "RUNNING" (
   @echo The %serviceName% service is already installed and running.
   exit /B 0
)

if "%serviceState%" == "" (
   set programName=enable
   call "%programDirectory%run-brltty" -I %*
   if !ERRORLEVEL! NEQ 0  exit /B !ERRORLEVEL!

   set programName=service
   call "%programDirectory%setvars-brltty"
   set logLevel=info

   for /F "usebackq tokens=1,2,*" %%A in (
      `reg query "%serviceKey%" /V "%commandValue%"`
   ) do (
      if "%%A" == "%commandValue%" (
         set commandData=%%C -U "!updatableDirectory!" -W "!writableDirectory!" -L "!logFile!" -l "!logLevel!"
         set commandData=!commandData:"="^""!
         reg add "%serviceKey%" /F /V "%commandValue%" /D "!commandData!"
         if !ERRORLEVEL! NEQ 0  exit /B !ERRORLEVEL!
         break
      )
   )
) else (
   @echo The %serviceName% service is already installed.
)

net start "%serviceName%"
exit /B %ERRORLEVEL%