Ciao.
Innanzitutto grazie per la pronta risposta
Purtroppo, però, sto trovando difficoltà a realizzare tale funzione.
codice:
import java.io.File;
import java.util.Map;
/**
*
* Title: Win32Launcher
* </p>
*
* Description: Launcher per sistemi windows
*
* visualizzatore
* </p>
*
* Copyright: Copyright (c) 2005
* </p>
*
* Company:
* </p>
*
* @author Eumene
* @version
*/
public class Win32Launcher implements Launcher {
/**
* Nome comando start
*/
public static final String START_COMMAND = "START.exe";
/**
* Avvia il software associato al file in input attraverso una chiamata al
* comando "start" presente nella path
*/
public void launch(File f) throws LaunchException {
try {
// Preparo processo
ProcessBuilder pb = new ProcessBuilder(START_COMMAND, f.getAbsolutePath().replaceAll("\\\\", "/"));
// Trasferimento enviroment a processo
pb.environment().clear();
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
pb.environment().put(envName, env.get(envName));
}
System.out.println(pb.environment());
// Lancio processo
pb.start();
} catch (Exception e) {
throw new LaunchException(LaunchException.PROGRAM_LAUNCH_ERROR, e);
}
}
public static void main(String argv[]) {
try {
System.out.println(System.getenv());
new Win32Launcher().launch(new File("D:/BackupMaster/Messenger LOG/jms2081278746.xml"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Il codice riportato è quello che sto provando ad utilizzare ma ricevo sempre l'errore
java.io.IOException: CreateProcess: START.exe "D:/BackupMaster/Messenger LOG/jms2081278746.xml" error=2
Puoi essermi di aiuto. Il file da aprire esiste, infatti credo che l'errore sta nel fatto che non trovo il comando "start"
Ho provato "start", "START", "start.exe", "START.exe" ma niente e come puoi vedere ho trasferito l'enviroment al processo in modo che la PATH sia giusta (PATH contiene %SystemRoot%\system32 come dicevi tu)
Grazie