For the script:
@echo off
title Applying Noah service rights, please wait...
cd c:/subinacl
subinacl /service NoahServer /grant=%Computername%\user=TOP
subinacl /service NoahClient /grant=%Computername%\user=TOP
pause
This script grants using Subinacl users administrative rights over certain services. However as you can see this is only for one user named(user) on the computer %Computername%.
I was wondering if there is a possibility to run the 2 lines starting with Subinacl for all users on the local computer.
Thanks
You can use WMIC
to get a list of user names defined on the computer, and then use FOR
to iterate over each one. The code sample below should get you started.
Be warned that the below does not attempt to filter out built-in or other "special" accounts. I am also unsure of quoting syntax as applies to SUBINACL
. I suggest you review it for desired behavior before removing the ECHO
lines in front of the SUBINACL
calls.
@echo off
title Applying Noah service rights, please wait...
cd c:/subinacl
FOR /F "usebackq" %%a IN (`WMIC UserAccount GET Name`) DO CALL :process_account "%%a"
pause
REM exit batch script file
EXIT /B
:process_account
SETLOCAL
REM strip any quotes from argument
SET ACCT=%~1
REM skip blank names
IF "%ACCT%"=="" EXIT /B
REM skip "Name" header from WMIC
IF "%ACCT%"=="Name" EXIT /B
ECHO Processing account: %1
REM remove the ECHO in front of SUBINACL once tested
ECHO subinacl /service NoahServer /grant="%Computername%\%ACCT%"=TOP
ECHO subinacl /service NoahClient /grant="%Computername%\%ACCT%"=TOP
REM return to CALLer
EXIT /B