Eventuali duplicati:
Get output from a process
Executing DOS commands from JavaCome per eseguire i comandi di Windows in JAVA e restituire il testo risultato come una stringa
Sto cercando di eseguire un comando cmd dall'interno di un Programma console JAVA es .:
ver
e quindi restituisce l'output del comando in una stringa in JAVA, ad es. Uscita:
string result = "Windows NT 5.1"
Perché il downvote? – Mike
Avresti dovuto cercare questo prima di fare questa domanda. Quando cerco [esegui comandi Windows in JAVA] (http://stackoverflow.com/search?q=run%20Windows%20commands%20in%20JAVA) in cerca di stackoverflow, ho ottenuto risultati inferiori ... http: // stackoverflow.com/questions/2935326/java-library-api-to-help-run-windows-commands http://stackoverflow.com/questions/4031390/executing-dos-commands-from-java http: // stackoverflow. it/questions/7112259/how-to-execute-windows-commands-using-java-change-network-settings –
Questo link ti aiuterà: https://www.codepuran.com/java/execute-dos-command- java/ –