How to open Windows Explorer (Windows+E) using Javascript - javascript

How do you open Windows Explorer (Windows+E) through Javascript?

You cannot open Windows Explorer through JavaScript because modern web browsers are locked down to offer virtually zero access to the client user's hard drive. An unpatched version of Internet Explorer 6.0 could have accessed Windows Explorer by browsing in a new window to file://c:/.

window.open wont work for local path or network path on modern browsers, you need to turn your path to URL like c:\data to file:///C:/Data/ or you can use HTML5 feature like below
<pre>
input type="file" name="itemImagePath"
</pre>
Another way to open folder in web browser is:
<pre>
Open folder
</pre>
mypc: your computer name
myfolder: folder you want to open

Only way to achieve that is to register custom protocol handler in client's operating system.
After that, any link related to that protocol would be sent to handler which would open desired application. In our case Windows Explorer.
Generally it supposed to work as "magnet:" links that are opening in BitTorrent clients.
Or like "mailto:" links that are opening in Mail applications.
How to register protocol handler in Windows you can find here:
Register Custom Handler # Microsoft
But be careful, letting Windows Explorer to open links from the network without any filtering is not very safe. It's strongly recommended to write separate handler program that will process link, filter out all danger parts, and than pass ready link to the OS.
So after all you can make installation package that every client would have to install to make it work, and everything is great if that solution is for fellows from intranet, but not for strangers in Internet.

Related

Is there a way to detect if MS Visio, MS Word, or any MS Office app is installed on computer from IE & Chrome?

I have a SharePoint 2019 document library wherein I have a custom JavaScript code to open the MS documents (Word, Excel, Ppt, Visio) in the client application. I am using Office URI schemes for opening the documents in client apps. However, if there is no client application installed on the computer, the Office URI scheme fails without throwing up any error. I want to know if there is a way to check from the browser (IE and Chrome) if a particular MS application (Visio, Word, etc.) is installed on the computer.
P.S. I have tried the ActiveXObject approach, but for some reason, it didn't work for me and, also I want a solution that will be cross-browser compatible and afaik ActiveXObject is supported only on IE.
(Current MSFT employee in Office here. On the team that owns the link invocation handling for the native client side but not the SharePoint or JS side)
The root problem is that the browser object model doesn't give you a result for navigating to the ms-word/etc links. As I understand it that is why the built-in SharePoint open UX has 2 options. One to open in the browser and another to open in the native client. And there is interstitial UX to prompt the user if the file did not successfully open in the native client.
(And, correct, the ActiveX solution will not work even with modern Edge on windows either and is a dead-end technology wise.)
You can try using ActiveX technology to instantiate Office application as described on the detect microsoft office version using javascript thread. But Chrome is not aware of COM technology. So, any code for creating an Office application instance will fail.

how to open link in internet explorer using html or any browser language?

I'm working on a new project and I need to open a link in Explorer with a click on button from Chrome or Firefox using any browser language.
I have search a lot and I found this code
I tried this i-explorer:https://www.google.com
<a class="mscom-link c-call-to-action c-glyph edgedownload" aria-label="Try Microsoft Edge" href="Microsoft-edge:https://microsoftedgewelcome.microsoft.com/?FORM=MK12CD&wt.mc_id=MK12CD" data-bi-name="try now" data-bi-id="n1c1m1r1a3" data-bi-type="text" data-bi-bhvr="TRIALSINITATE"><span class="x-hidden-focus">TRY NOW</span></a>
This code open the link in microsoft edge but I want to open it on internet explorer I've taken this code from this https://www.microsoft.com/en-gb/windows/microsoft-edge.
You can try to open microsoft edge.
Please don't tell me to use extensions I know that.
I think it's possible to do that. Thanks alot.
The only way to do it without a plugin would be to add a protocol handler to the registry on your machine. Edge does it out of the box because it contains one - just like any other application that is capable of opening links to specific applications, (Skype and Steam for example).
Obviously adding it onto your machine won't distribute onto other machines and this cannot be achieved from a web page.
For example:
Skypes protocol handler would be:
Skype
Sadly, IE does not have one.
If you want to view the protocols - you'll find them in RegEdit- under HKEY_CLASSES_ROOT. For example the edge one will be under microsoft-edge folder, and you want to open the String option titled "URL Protocol". You'll find all available protocols on your system inside the key mentioned above.
While there isn't an existing protocol handler for IE, you can easily create one:
https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)

Possible to open link in Chrome Application from javascript?

From the command line, I can open a url as a chrome application by running e.g.
chromium --app=https://www.stackoverflow.com
Is it possible to do open a url in this mode from javascript in an existing page? To be clear, the url should ideally be opened in a new window, which has the properties implied by the --app flag (e.g. no address bar), whether or not the current page is running in that mode.
My reason for asking is that I'd like to integrate this into vimium.
There is no way to do what you need directly from Javascript. I think you'll need to create an Chrome extension to do that.
You still can find an extension called "Open with external application" which do that, but its use NPAPI and NPAPI is not supported anymore by latest Chrome version. The source is hosted on BitBucket.
The new way to do the same thing is using the native messaging API. In this case the external application would have to register a native messaging host in order to exchange messages with your application. You can see more at http://developer.chrome.com/extensions/messaging.html#native-messaging

Is it possible to open Internet Explorer window from Firefox? [duplicate]

Our Web application is based on IE9, which means only IE9 can open the pages in our site. We'll prevent user to browse our site when their browser is not IE9.
But sometimes we had to send a link to user's email box to complete some actions and they will open the link directly with their default browser, the problem is here, if the default browser is not IE9 then they can't open the link, they have to copy the link to IE9. Our user don't want do this manually, they want open the link in IE9 directly no matter what the default browser is.
I have tried using ActiveXObject, but it only works in IE. I want have a script which can open IE browser in Firefox/Chrome page.
It sounds like you want to have a link in an email that activates a specific program on the user's computer rather than the program that they've identified should be used (e.g., their default browser). I don't believe you can do that.
You can install "protocol handlers" in both Chrome and Safari (I suspect Firefox as well), which would let you send a link like ie://example.com/path/to/app. Your protocol handler would launch IE and take you to the relevant site. (Apple does this with iTunes.) But your users would have to install the handler (and, of course, you'd have to write it).
An easier answer might be to have the users install any of the ubiquitous "open in IE" add-ons/extensions that exist for Chrome, Firefox, etc. They follow the link, then choose "open in IE" from some kind of menu. (If they're using webmail, they may even be able to right-click the link and choose that line item, depending on the extension.)
Side note: Obviously, though, barring it being impossible I'd recommend making your application compatible with Chrome and Firefox.
No you can't do it..
but there is some alternatives:
Install your users IE tab:
FireFox - http://lifehacker.com/135297/internet-explorer-in-a-firefox-tab?tag=softwarewebpublishing,
Chrome - https://chrome.google.com/webstore/detail/hehijbfgiekmjfkfjpbkbammjbdenadd
Use a batch file that will launch your link in explorer.
use this Firefox plugin makes it possible to use (host) ActiveX controls in Firefox - http://code.google.com/p/ff-activex-host/
instead of ActiveX try using Netscape Plugin Application Programming Interface (NPAPI) - a cross-platform plugin architecture used by many web browsers.
Similar as with a batch file, you may create a link file to the page you need using the ".website" file extension with IE, which is configured in windows by default to open with ie. Put it in your webserver public folder and then add a link to that file in your website
You don't have to write code to create a custom protocol handler in Windows. See this page for how to define one in the registry.
You can use User agent switcher for chrome or firefox
For Chrome :
https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg
For Firefox :
https://addons.mozilla.org/en-US/firefox/addon/uaswitcher/

How to create web app shortcut on user's desktop programmatically?

For enterprise intranet web application, is there any way to create a desktop shortcut of web application on user's desktop? I'm looking for functionality similar to Google Gears, but without installing Google Gears. I'm looking to give user's a link on web application that says "Click here to install desktop shortcut", when they click on it, a desktop shortcut is installed with the custom icon for our application. Is there a way to do it using javascript or any other client side technologies? I don't want to run any exe on user's machines. Even though it's intranet, I have to jump through lot of corporate hoops, compliance approvals, etc to run exe on their machine. We are trying to avoid that, due to time constraints. User machines are windows XP with IE6 installed. They may all upgrade within next year's time to Windows 7 with IE8. Intranet web application in question is developed using asp.net 3.5, c#.
If this is really a corporate environment then just go talk to the network operations team.
It should be trivial for them to add something to the login script to push this link to the people's desktops.
More Info:
http://www.petri.co.il/forums/showthread.php?t=6154
http://social.technet.microsoft.com/Forums/en/winserverGP/thread/02a7bfbb-180f-40eb-82e3-2343b2bf31eb
Alright, at first I thought that this was an impossible task, until I realized that it's not.
A shortcut is just a file, and we all know you can download files from links.
I'm not sure how well windows shortcuts can be transferred from computer to computer, but I would assume that a shortcut with a location like http://www.google.com/ is not tied to any specific windows machine.
You could zip the shortcut, and point the link to the location of the zip file. Tell the users to unzip the file and place the shortcut. You may be able to just serve the shortcut, but you'd have to give the right headers, and probably specify application/octet-stream or something like it.
Alternatively you can tell them to right click, go to new -> shortcut, and copy-pasta the url into the location box.
Alternatively you could write a batch file for the users to download that opens a url in the default browser.
I know it's not quite as direct as click-button -> receive bacon but it will work.
Try looking at SaveAs
document.execCommand("SaveAs", false, "url to desktop");
The user will still have to click save and it only saves a HTML page. You would have to open a hidden IFrame containing a web application and call .execCommand on the iframe's document.`
You can create a shortcut (.lnk) file in a directory in your site and put it as the Url for a hyperlink so the users right click and save as they download the .lnk file. Your server will need the mime-type .lnk application/x-ms-shortcut adding.
The icon can be done by putting it on a network location and using the "Change icon" function to refer to this network location. This works on Windows. I suppose it could be adapted for each OS required?

Categories