Psexec命令异常行为

时间:2013-11-19 18:53:22

标签: batch-file windows-server-2008 remote-access psexec

我在代码下面运行:

master.bat:

@echo off
call :Commands >D:\Test\log.txt
exit /b

:Commands
@echo off
setlocal
for /F "delims= " %%i in (D:\Test\servers.txt) do ( psexec \\%%i -c D:\Test\script.bat )
exit

WHERE ...

servers.txt:

server1 
server2
server3

script.bat:

taskkill /F /IM notepad.exe
taskkill /F /IM firefox.exe
taskkill /F /IM explorer.exe

我正在运行 master.bat 放在server2上,一切正常但我面临的问题是:我在本地server2上验证了脚本运行成功但是没有本地日志server2进入 log.txt 文件,如下所示,而server1和server3的日志按预期进行:

log.txt的:

C:\Windows\system32>taskkill /F /IM notepad.exe 
SUCCESS: The process "notepad.exe" with PID 8932 has been terminated.
C:\Windows\system32>taskkill /F /IM firefox.exe 
SUCCESS: The process "firefox.exe" with PID 7580 has been terminated.
C:\Windows\system32>taskkill /F /IM explorer.exe 
SUCCESS: The process "explorer.exe" with PID 8932 has been terminated.

C:\Windows\system32>taskkill /F /IM notepad.exe 
SUCCESS: The process "notepad.exe" with PID 7586 has been terminated.
C:\Windows\system32>taskkill /F /IM firefox.exe
SUCCESS: The process "firefox.exe" with PID 8032 has been terminated.
C:\Windows\system32>taskkill /F /IM explorer.exe  
SUCCESS: The process "explorer.exe" with PID 7530 has been terminated.

为什么PsExec命令会出现这种异常行为?

编辑:运行master.bat后,server2上的cmd屏幕输出:

我再次交叉检查,脚本在server2上成功运行,并且从cmd屏幕也可以看到,但仍然没有登录到server2的日志中。我测试了-accepteula选项也没有改变行为。我在这里放置我的cmd屏幕输出:

PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting D:\Test\script.bat on server1...
script.bat existed on server1 with error code 0.

PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

D:\Test\script.bat existed with error code 0.

PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com

Starting D:\Test\script.bat on server3...
script.bat existed on server3 with error code 0.

0 个答案:

没有答案
相关问题