我有一个用户login脚本。 我想根据主机名安装打印机。 在此文件夹\ domain.local \ SYSVOL \ domain.local \ Policies {DF3F608C-8D78-934F-B79F-1965F3C4409B} \ User \ Scripts \ Logon
我有每个主机/工作站的cmd文件和logon.cmd。
terminal服务器遵守环境variables%clientname%,但工作站不是。
logon.cmd的相关区域
rem Delete all existing printer connections c:\windows\system32\con2prt.exe /f rem Call workstation specific script for connecting to printers %clientname%.cmd
摘自clientname.cmdL:
rundll32 printui,PrintUIEntry /in /n\\fileserv\PhaserPS rundll32 printui,PrintUIEntry /in /n\\fileserv\CanonIR rundll32 printui,PrintUIEntry /y /n\\fileserv\CanonIR
除非您通过RDP连接到计算机,否则variables%CLIENTNAME%不存在。 你应该改为调用%COMPUTERNAME% 。
您可以为使用%CLIENTNAME%的terminal服务器指定不同的脚本。 或者你可以在你的脚本中写一个条件,如果它存在,将使用%CLIENTNAME%如果没有,则尝试使用%COMPUTERNAME% 。
Zoredache是对的。 另外,如果你想检查一个variables是否为空,你可以这样做:
if not "%CLIENTNAME%"=="" echo all your code goes here
如果你省略了引号,批处理解释将会看到“如果不是==回显你的所有…”并抛出一个错误。