Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何将用户列表输入到批处理文件中_Batch File - Fatal编程技术网

Batch file 如何将用户列表输入到批处理文件中

Batch file 如何将用户列表输入到批处理文件中,batch-file,Batch File,我希望将users.txt中保存的用户列表输入到批处理文件中,以重置权限。当我放置*时,它将进入文件夹列表并正确重置权限,但我想限制权限设置的范围。列表中的每个用户都对应于我要重新授予权限的文件夹的名称 这个脚本可以工作,但是可以在每个文件夹上工作,我不能限制它的范围 cd C:\Users\matt\desktop\subinacl for /D %%i in (*) do ( subinacl /file %%i /perm /grant=%%i=C "/grant=\domain ad

我希望将users.txt中保存的用户列表输入到批处理文件中,以重置权限。当我放置*时,它将进入文件夹列表并正确重置权限,但我想限制权限设置的范围。列表中的每个用户都对应于我要重新授予权限的文件夹的名称

这个脚本可以工作,但是可以在每个文件夹上工作,我不能限制它的范围

cd C:\Users\matt\desktop\subinacl

for /D %%i in (*) do (

subinacl /file %%i /perm /grant=%%i=C "/grant=\domain admins=f"  "/grant=system=f"         "/grant=creator owner=f" /setowner=%%i 
subinacl /subdirectories %%i\* /perm /grant=%%i=f "/grant=domain admins=f"   "/grant=SYSTEM=f" "/grant=creator owner=f" /setowner=%%i )
这就是我试图做的,但使用文件夹名称列表来重新许可这些文件夹,并且它不起作用。它将users.txt输入grant=位置,而不是实际列表

cd C:\Users\matt\desktop\subinacl
SET users=users.txt

for /D %%i in (%users%) do (

subinacl /file %%i /perm /grant=%%i=C "/grant=domain admins=f"  "/grant=system=f"  "/grant=creator owner=f" /setowner=%%i 
subinacl /subdirectories %%i\* /perm /grant=%%i=f "/grant=domain admins=f" "/grant=SYSTEM=f" "/grant=creator owner=f" /setowner=%%i )
任何帮助都将不胜感激。我希望从用户列表调用到批处理文件中。

@echo off
cd C:\Users\matt\desktop\subinacl
SET users=users.txt
对于/f“delims=“%%i in(%users%)do(
对于/D%%i in(*)do(
echo subinacl/file%%i/perm/grant=%%i=C“/grant=domain admins=f”“/grant=system=f”“/grant=creator-owner=f”/setowner=%i
回显子目录%%i\*/perm/grant=%i=f”/grant=domain admins=f”“/grant=SYSTEM=f”“/grant=creator owner=f”/setowner=%i
)
)

我没有使用subinacl,所以我只是重复了建议的命令

就个人而言,我建议使用您的原始版本设置管理员等权限,然后使用
users.txt
文件设置个人权限。正如我所列出的,admin等perms将再次应用于
users.txt