Command output as string
- by rik
I want to get output from command C:\Program Files (x86)\Java\jre7\bin\java.exe" -version as string variable.
I tried this way:
$out = &"C:\Program Files (x86)\Java\jre7\bin\java.exe" -version
but it gives error message:
java.exe : java version "1.7.0_05"
At line:1 char:9
+ $out = & <<<< "C:\Program Files (x86)\Java\jre7\bin\java.exe" -version
+ CategoryInfo : NotSpecified: (java version "1.7.0_05":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing)
$out variable seems empty.
What am I doing wrong?