I'm trying to run multiple commands remotely using psexec.
I launch psexec from a local computer then specify the remote computer to connect.
I want to store the output of the remote command on my local pc that initiated the psexec command.
If use ">" or ">>" the file gets created on the remote pc, not on my local pc.
Here is the code that I use:
cmd /c "c:\windows\system32\psexec.exe" \\192.168.0.2 -accepteula -u test -p test -s cmd /k (date /t) ^& (time /t) ^& (hostname) ^& (wmic csproduct get name, identifyingnumber) ^& (net statistics workstation) ^& (wmic LOGICALDISK LIST BRIEF) ^& (echo.) ^& (net use) ^& (tasklist)'+' ^& (echo.) ^& (echo. LISTARE CONTINUT FISIER HOSTS:) ^& (type c:\windows\system32\drivers\etc\hosts)
What am I doing wrong?
Best Answer
That is how PSExec works, on the other computer. WMIC can do what you want all by itself.
or
computerlist.txt looks like this
so you can mix 'n match names or ip addresses.
or
Although wmic does do redirection. Use
Append
instead ofoutput
to append.See
wmic /?
,wmic /output /?
, andwmic /format /?
.Also wmic can run programs invisible on other computers.
Because 127.0.0.1 is a local address you'll see notepad but won't see it on a remote computer. See
wmic process call create /?