我有一台名为MY_MACHINE的Windows 7机器 我想连接到名为REMOTE_SERVER的Windows Server 2012 我使用psexec 2.11版本。
当我测试时,我无法获得计算机名称= REMOTE_SERVER
的OK结果第一次测试:
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /c echo %%computename%%
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
%%computename%%
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.
第二次测试:
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /c echo %computename%
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
%computename%
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.
第三次测试:
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /c echo %%computername%%
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
%MY_MACHINE%
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.
4º测试:
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /v /c "echo %%computername%%"
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
%MY_MACHINE%
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.
5º测试:
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /v /c "echo ^%computername^%"
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
%computername%
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.
有关它的任何建议吗?
答案 0 :(得分:2)
解决方案使用^%computername ^%不带引号“
C:\Tests\Tools>PsExec \\REMOTE_SERVER.OTHERDOMAIN.local -u OTHERDOMAIN\ONE_USER
-p **PASS** cmd.exe /v /c echo ^%computername^%
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
REMOTE_SERVER
cmd.exe exited on REMOTE_SERVER.OTHERDOMAIN.local with error code 0.