Is there any way to do this through Java or Javascript, given the link as a String? I've been looking but I've only found topics about Android devices, I'm asking for a Windows PC.
I hadn't planned on learning how to write an extension with the proper permissions for Chrome for this, but if that's the only way then so be it.
To run any executable including Chrome in JAVA:
If the path to the application is a system variable:
String location = System.getenv("APPVARIAVLE");
Process process = new ProcessBuilder(location).start();
Or if you want to use the fully qualified path:
Process process = new ProcessBuilder("C:\\location\\MyApp.exe").start();
The JavaDoc for the process builder say that you can add parameters like this:
new ProcessBuilder("myCommand", "myArg1", "myArg2");
The argument for incognito looks like it is: "-incognito" and to open a url just add the url: "example.com".
Which means that you can most likely can add the url and incognito arguments the following way to chrome in the arguments:
Process process = new ProcessBuilder("C:\\YourChrome\\Location\\chrome.exe","-incognito","http://stackoverflow.com").start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With