Opening a file system folder / directory from a web browser

I am distributing my desktop application to flash drives to thousands of users on Windows, Mac and Linux. I have an HTML start page that has links to documentation, installation guides, release notes, etc. that are on the flash drive. I would like the user to simply install directly from the browser, but it is exactly what antivirus programs are trying to prevent (and rightly so). Instead of trying to start the installer, just find the installer and let the user perform the last step.

Is it possible to make the file system manager (Explorer, Finder, etc.) open the folder containing the file on the host computer and select it? I guess this will require JavaScript, and it will probably be different for Windows, Mac, and Linux. Also, work in most browsers (IE, FF, Chrome, Safari, Opera).

Is it on the same complexity scale to solve Fermat's last theorem?

thanks

+4
source share
2 answers

This JS code should work for IE and Firefox on Windows if the page was loaded from your local file system. You will need to test this on Linux / OSX. I do not know how you will approach the chrome / safari / opera.

function execute(command, commandParam) { if (isIE()) { try { activexShell = new ActiveXObject("Shell.Application"); activexShell.ShellExecute(command, commandParam, "", "open", "1"); exit(); } catch (e) { alert("exception " + e.name + ': ' + e.message); } } else { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var FileFactory = new Components.Constructor("@mozilla.org/file/local;1","nsILocalFile","initWithPath"); var program = new FileFactory(command); var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces. nsIProcess); process.init(program); process.run(false, commandArray, commandParam.split(" ").length - 1, {}); exit(); } catch (e) { alert("exception " + e.name + ': ' + e.message); } } } 

Of course, you may need to sign the .js file to make it work. For more information see here http://www.mozilla.org/projects/security/components/signed-scripts.html

+2
source

Nope. Browsers (or most of them *) prevent this behavior. They have a wall between your actual file system and the content that the web serves you. Only HTML input control violates this, and they have quite a bit of protection around this too.

* - You can use the ActiveX IE control, but it is only IE.

+1
source

All Articles