I have Windows 7 machine named MY_MACHINE.
I want connect to Windows Server 2012 named REMOTE_SERVER.
I use psexec 2.11 version.
When I test, I cannot get the OK result that is Computer Name = REMOTE_SERVER
First test:
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.
Second test:
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.
Third test:
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º test:
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º test:
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.
Any suggestions about it?
Solution using ^%computername^% without quotes "
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.