Tuesday, 15 May 2018

command line - 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?



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

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...