subinacl get full output

1k views Asked by At

We are using the windows console program subinacl.exe to grant a user the right to stop and start a service. Therfore we use the following command:

subinacl.exe /service %SERVICE_NAME% /grant=%PC_NAME%\%USER_NAME%=PTO

where

  • %SERVICE_NAME% = name of the service
  • %PC_NAME% = name of the computer
  • %USER_NAME% = name of the user that should become the right to start and stop the service
  • PTO = right to start and stop the service (R would be just reading)

When typing the command into the default windows command line (with administrator rights) on a windows server 2012 the result is:

ELITE_INETRSVSERVER : delete Perm. ACE 4 test-pc\test
ELITE_INETRSVSERVER : new ace for test-pc\test
ELITE_INETRSVSERVER : 2 change(s)


Elapsed Time: 00 00:00:00
Done:        1, Modified        1, Failed        0, Syntax errors        0
Last Done  : ELITE_INETRSVSERVER

Now we want to save the text into a file or get it into a programm (via redirect the outputs : Getting output from a shell/dos app into a Delphi app). We need the integer values of Done and Failed found in the result.

The problem is, that we cannot catch the last three lines after the empty lines.

When using console redirect, the first three lines can be found in the file result.txt. But the last three are shown in the console.

subinacl.exe /service %SERVICE_NAME% /grant=%PC_NAME%\%USER_NAME%=PTO > result.txt 1<&2

The same problem we do have, when redirecting the output programmatically.

Of course every command is executed as administrator.

1

There are 1 answers

0
Rubén Pozo On

The option /errorlog could help to solve the problem:

subinacl /outputlog=c:\NONERRORS.TXT /errorlog=C:\ERRORLOG.TXT /file C:\TEST.TXT /display

if C:\ERRORLOG.TXT file is empty it means that the command has been executed successfully.