java.exe -version and pushd?

I have noticed that when I run the following command

Pushd \\RemoteMachine\C$ && java.exe -version

I get the java version of the computer I am on. However when I run the pushd command with a search option like the command below I get the actual information found on that computer.

Pushd \\RemoteMachine\C$ && dir /s java.exe

Why is this the case? Is it possible to run java.exe -version on a remote PC and have it output that computers information on my screen?


Solution 1:

PsExec by SysInternals does exactly what you need it to. Your example would be:

psexec \\RemoteMachine java.exe -version

Solution 2:

Although PsExec would get the job done I am unable to use that.

I am able to perform the command java.exe -version on the remote machine by changing the directory once I used pushd.

Pushd \\RemoteComputer\C$
cd "Program Files\Java\jre6\bin"
Java.exe -version

Or all at once

Pushd \\RemoteComputer\C$ && cd "Program Files\Java\jre6\bin" && java.exe -version && popd