简体   繁体   中英

Using Java to interact with the Windows OS

Which method is the best way to query and return data from Windows OS using java? I have used the exec() method to query calls to the command line, but that can be a pain when writing complex OS call queries.

Would PowerShell be the recommended way to query data from the Windows OS using Java? If so how can I go about it in Java?

Examples of Windows OS call queries would be from returning host details, memory(RAM) details , to closing and opening logical ports (security reasons) , and much more that can't be done via internal Java.

Thanks, much appreciated.

Consider Apache Commons Exec

It is a robust and reliable library to execute external processes from Java-code.

Here is the javadoc for this library

嘿,我认为这可能会有所帮助

Process powerShellProcess = Runtime.getRuntime().exec(cmd);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM