none
使用Ntrights.exe配置客户端的登录权限 RRS feed

  • 问题

  • 公司要求每台客户端计算机仅允许它的Owner登录,我们准备使用Ntrights配置客户端权限。

    脚本如下:

    @echo off
    (
    For /F " tokens=1,2 delims=" %%i in (list.txt) Do Ntrights.exe -m \\%%i -u %%j +r SeInteractiveLogonRight
    For /F " tokens=1,2 delims=" %%i in (list.txt) Do Ntrights.exe -m \\%%i -u "builtin\users" -r SeInteractiveLogonRight
    For /F " tokens=1,2 delims=" %%i in (list.txt) Do Ntrights.exe -m \\%%i -u "builtin\guest" -r SeInteractiveLogonRight
    )>log.txt 2>&1<nul
    echo Completed, please see log.txt?
    pause

    文本格式:

    ComputerName          domainname\adaccount

    但是我们遇到2个问题,需要大家帮助

    1. 脚本中的%%j无法调用list.txt中的域账号那列数据

    2. 如何将成功执行的日志与失败的分别记录在不同的文本中

    • 已移动 Amy Wang_Moderator 2016年9月23日 4:59 Unrelated to Windows Server Technical Preview
    2016年9月23日 2:02

全部回复

  • Hi Daniel,

    >>1. 脚本中的%%j无法调用list.txt中的域账号那列数据

    你的运行的命令我一条条看了语法什么都是正确的.

    对于第一个问题,请尝试下这样看看:

    For /F " tokens=1-2 delims= " %%a in (list.txt) Do Ntrights.exe -m \\%%a -u %%b +r  SeInteractiveLogonRight

    注意delims后面的空格,如果你的list文中是用空格隔开的话!

    另外最好再仔细查看下list文件看看有没有特殊字符或者什么的.

    >>2. 如何将成功执行的日志与失败的分别记录在不同的文本中

    你可以尝试使用if..else语句,比如if(设置成功){log 记录机器名}else{记录失败的机器名用户名}

    此外,请问你现在用的是不是server 2003?(support ended on July 14 2015)如果是请升级OS,这样我们就可以用很多其他办法去实现它!

    参考文档:

    https://support.microsoft.com/en-us/kb/315276

    Best regards,

    Andy_Pan


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    2016年9月26日 3:19
    版主
  • Hi Daniel,

    这个问题解决了么?

    如果没有,或者你需要更多帮助请在这里反馈下谢谢!

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    2016年10月6日 7:37
    版主