简体   繁体   English

subinacl获得完整的输出

[英]subinacl get full output

We are using the windows console program subinacl.exe to grant a user the right to stop and start a service. 我们正在使用Windows控制台程序subinacl.exe授予用户停止和启动服务的权利。 Therfore we use the following command: 因此,我们使用以下命令:

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

where 哪里

  • %SERVICE_NAME% = name of the service %SERVICE_NAME% =服务名称
  • %PC_NAME% = name of the computer %PC_NAME% =计算机名称
  • %USER_NAME% = name of the user that should become the right to start and stop the service %USER_NAME% =应该有权启动和停止服务的用户名
  • PTO = right to start and stop the service (R would be just reading) PTO =启动和停止服务的权利(R只是读取)

When typing the command into the default windows command line (with administrator rights) on a windows server 2012 the result is: 在Windows Server 2012上的默认Windows命令行(具有管理员权限)中键入命令时,结果为:

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 ). 现在,我们想将文本保存到文件中或将其保存到程序中(通过重定向输出: 从shell / dos应用程序将输出获取到Delphi应用程序中 )。 We need the integer values of Done and Failed found in the result. 我们需要在结果中找到Done和Failed的整数值。

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 . 使用控制台重定向时,可以在文件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. 当然,每个命令都是以管理员身份执行的。

The option /errorlog could help to solve the problem: / errorlog选项可以帮助解决问题:

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. 如果C:\\ ERRORLOG.TXT文件为空,则表示命令已成功执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM