简体   繁体   中英

uninstall a software programmatically in Java

I want to know if there is a way to uninstall 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.

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