uninstall a software programmatically in Java
I want to know if there is a way to uni开发者_开发百科nstall a software programmatically using java.
Suppose if I have Firefox installed on my windows machine then how could I use java program to uninstall it.Well, you could try and use Runtime.getRuntime().exec( ... )
and run the WMIC
command line tool.
For other platforms you could execute other command line programs (like aptitude
etc.).
You can try invoking Firefox's uninstall program, C:\Program Files\Mozilla Firefox\uninstall\helper.exe
, using ProcessBuilder
. For example:
Process p = new ProcessBuilder("C:\\Program Files\\Mozilla Firefox\\uninstall\\helper.exe").start();
You have to differenciate what you want to do:
At first ask yourself:
- How can I uninstall software programmatically, regardless on how to do this with Java. This should be a distinct question on stack overflow. And it is just platform dependant and has nothing to do with Java.
Now ask:
- How can I call external command line tools / call the windows API / do this or that from Java.
精彩评论