Pesquisando quase exatamente esse problema, deparei-me com este tópico do fórum de technet .
A postagem relevante no tópico:
post on sysinternals by user bnyffele
I actually found that there is no difference between the various systems, but it depends on how you address the remote machine:
psexec \hostA cmd -> seperate window opens (if command is executed on \hostA)
psexec \127.0.0.1 cmd -> cmd prompt in same window
psexec \[IP address] cmd -> cmd prompt in same window
psexec \localhost cmd -> results in error message about localhost being a duplicate name.
psexec \hostA.domain.com -> cmd prompt in same window
So, it seems that I only get a separate window, when I am executing psexec for the local machine and I am using the short hostname.
Parece que, se você especificar o endereço IP do host local como a máquina para executar o comando, obterá a saída. Eu testei isso sozinho e, embora não tenha imprimido a saída padrão em tempo real, imprimiu tudo no mesmo terminal quando o script terminou.
Se você estiver tentando descobrir como fazer isso usando o nome do sistema em vez do endereço IP, ainda poderá fazê-lo, adicionando um ponto ao final do nome do host, conforme determinado por outro usuário várias mensagens posteriormente no mesmo fio.
post on sysinternals by user bluechipps
Actually i just discovered a workaround that is almost painless. All you have to do is add a '.' after the shortname and it will still function the same but will then output properly to the same cmd window! Note the differences.
PS C:> psexec \hal ipconfig
PsExec v1.95 - Execute processes remotely
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
ipconfig exited with error code 0.
PS C:>
PS C:> psexec \hal. ipconfig
PsExec v1.95 - Execute processes remotely
Copyright (C) 2001-2009 Mark Russinovich
Sysinternals - www.sysinternals.com
Windows IP Configuration
Ethernet adapter Local Area Connection 2:
Connection-specific DNS Suffix . :#####
Link-local IPv6 Address . . . . . :#####
IPv4 Address. . . . . . . . . . . :#####
Subnet Mask . . . . . . . . . . . :#####
Default Gateway . . . . . . . . . :#####
ipconfig exited on hal. with error code 0.
PS C:>