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?
Answer
When you run java.exe in your example, the shell only searches the current directory (i.e. \\RemoteMachine\C$) but not its subdirectories. (In other words, it's more like dir java.exe without the /s.)
Since there is no such file in the remote machine's C:\, the next step is to search the directories specified in your %PATH% environment variable (which normally only contains local directories).
To solve your problem, specify the full path to java.exe. You don't even need to use pushd:
C:\> "\\RemoteMachine\C$\Program Files\Java\jre6\bin\java.exe" -version
No comments:
Post a Comment