我有一个系统,我使用一个简单的psexec脚本和服务器列表自动closures列表中的服务器,如果达到温度阈值或UPS只剩下几分钟的电池。 这是由AVTech设备pipe理器执行的。 它已经不在工作了(自从我来到这里之后可能还没有)。 如果我从pipe理命令提示符(Windows Server 2012 R2)手动执行该脚本,我得到此错误
The filename, directory name, or volume label syntax is incorrect.
有问题的脚本看起来像这样
c:\avtech\psexec @c:\avtech\scripts\serverlist.txt c:\windows\system32\shutdown.exe -s -f -t 0 >"c:\avtech\log\shutdownlog.txt 2>&1
而serverlist.txt文件当前是一个只有一个条目的文件
server.domain.local
如果我replaceserverlist.txt文件的实际服务器名称,它工作正常
C:\Windows\system32>C:\AVTECH\psexec \\server.domain.local c:\windows\system32\shutdown.exe -s -f -t 0 >c:\shutdownLog.txt 2>&1
因此,如果我没有从服务器列表中获取psexec,那么这一切都可以正常工作。 而且,是的,服务器列表的path是正确的。
毫无疑问,这里有一个简单而明显的错误,但是我对这种事情的经验相当薄弱,有什么想法?
为什么不直接用/m开关调用shutdown.exe ,而不是用psexec来摆弄这个呢?
shutdown.exe -m \\server.domain.local -s -f -t 0
您甚至可以使用for命令将您的服务器列表保存在同一个文件中。 如果要使用非默认(空格和制表符)分隔符,请参阅for documentation :
for /f %%SERVER in (c:\avtech\scripts\serverlist.txt) do ( shutdown.exe -m %%SERVER -s -f -t 0 )
我可以推荐PsShutdown吗? 你似乎更倾向于PsTools,但我不认为PsExec是适当的工具。
对于关机-m,你可以用for循环遍历它,我想?
我倾向于这样使用它:
psexec.exe \\LAB-PC1 -u LAB-Pc01\admin -p S3cret! -i -d cmd /c shutdown /r /f /t 1
命令行分解:
(psexec部分)
(cmd部分)
您可以使用@ server-list.txtreplace我的\ LAB-PC1,并将其应用于主机列表
编辑
C:\Users\LabAdmin\Desktop\push_software_installer>SO-psexec-server-list.cmd C:\Users\LabAdmin\Desktop\push_software_installer>\\lab.local\central-store\Software\psTools\psexec @server-list.txt -u LABDOMAIN\administrador -p S3cret!! -i -d cmd /c w32tm /monitor > output.txt PsExec v1.98 - Execute processes remotely Copyright (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com Starting cmd on LAB-PC1...e on LAB-PC1... cmd started on LAB-PC1 with process ID 30820. <==== Couldn't access LAB-PC2-disabled: O identificador Ú invßlido. Couldn't access LAB-PC3-disabled: O identificador Ú invßlido. Couldn't access LAB-PC4-disabled: O identificador Ú invßlido. Couldn't access LAB-PC5-disabled: O identificador Ú invßlido. Connecting to LAB-PC5-disabled... C:\Users\LabAdmin\Desktop\push_software_installer>`
我的服务器列表.txt
LAB-PC1 LAB-PC2-disabled LAB-PC3-disabled LAB-PC4-disabled LAB-PC5-disabled
注意:我的实验室电脑语言在PT-PT
它在我的工作:)
希望能帮助到你