HostInfoCmdWin implements ICommand { public void getHostUUID() throws TAException, IOException { CommandLine command = new CommandLine("wmic"); command.addArgument("path"); command.addArgument("Win32_ComputerSystemProduct"); command.addArgument("get"); command.addArgument("uuid", false); Result result = ExecUtil.execute(command); if (result.getExitCode() != 0) { log.error("Error running command [{}]: {}", command.getExecutable(), result.getStderr()); throw new TAException(ErrorCode.ERROR, result.getStderr()); } log.debug("command stdout: {}", result.getStdout()); if (result.getStdout() != null) { String[] resultArray = result.getStdout().split("\n"); if (resultArray.length >1) { context.setHostUUID(resultArray[1]); log.debug("Host UUID: " + context.getHostUUID()); } else { log.error("[wmic path Win32_ComputerSystemProduct] does not return uuid"); } } else { log.error("Error executing the [wmic path Win32_ComputerSystemProduct]"); } } HostInfoCmdWin(TADataContext context); @Override void execute(); void getHostUUID();  }
@Test public void testGetHostUUID() throws Exception { System.out.println("getHostUUID"); TADataContext context = new TADataContext(); HostInfoCmdWin instance = new HostInfoCmdWin(context); instance.getHostUUID(); }