Encontrar y abrir cualquier archivo .exe en C:/
Frecuentes
Visto 76 equipos
0
I'm trying to create a small Java program that allows you to ask it to open an .exe file in a java window I created.
Here's a small example of what I want
User: Open chrome Program: starts looking for a file called chrome.exe in C:/ and opens it
And that for any .exe file.
Is there any way to achieve this in Java? Thanks!
2 Respuestas
2
exec(String command, String[] envp, File dir)
Ejecuta el comando de cadena especificado en un proceso separado con el entorno y el directorio de trabajo especificados.
comando es la ubicación del .exe
envp puede ser nulo
dir is the directory of your .exe
With respect to your question it should be...
Runtime.getRuntime().exec("c:\\program files\\chrome\\chrome.exe", null, new File("c:\\program files\\chrome");
Respondido 12 Feb 14, 08:02
0
Process p = Runtime.getRuntime().exec("cmd /c start "+file.getAbsolutePath());
how to run the exe file
and to find files(search) have a read at Java: busque archivos .txt en la carpeta especificada
contestado el 23 de mayo de 17 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas java external-process or haz tu propia pregunta.
Sí.
Process process = Runtime.getRuntime().exec("Dummy.exe");
- MarounYou need to recursively search the file tree from the start (
/
) to find your program, this is exactly whatFiles.walkFileTree
está diseñado para hacer. - Boris the Spider