I want to make the Windows calculator open when a user clicks a <a>
or a :<button>
<button onclick="window.open('file:\\\C:\Windows\System32\calc.exe')">
abrir calculadora
</button>
<a href = "C:\Windows\System32\calc.exe"> ir </a>
What I get is that the calculator is downloaded and if I click on it it runs, but what I want is for it to run directly.
The idea is to know what it would look like in the HTML to launch it later in Angular. I mention it in case Angular can manage it better, although I have looked at information and I don't see how to launch it from Angular.
For security, applications cannot be automatically launched from the browser, but operating systems allow applications to be integrated through custom URIs.
On Windows you can associate the Windows calculator to the custom URI by
calculadora://
following the instructions in the Microsoft documentation .Creating a custom URI on Windows
We create a file called
calculadora.reg
that contains the following content (you have to type the name of the file in quotes if we use notepad so that it does not add.txt
at the end):After saving the file we double click on it to add it to the Windows registry.
If you are not the Administrator user you will need to open a Command Prompt window as Administrator by right-clicking on the application and then clicking Run as administrator .
Once in a command prompt as Administrator user we type:
Where
<ruta>
is the path where you saved the file generated above.The custom URI is already defined, now we must create the HTML that uses said URI.
Using a custom URI in HTML
Now we modify our HTML, to make use of the custom URI we've created, as follows:
If you use Chrome, you will get a security warning that you can remove if you check the option "Always open this type of link in the associated application".
PS: This procedure varies on Linux operating systems. If any client uses it, let me know and I'll tell you how to proceed in that case.
what you ask can not be done, because the browser can not go out of its scope. If you think about it, it has its logic, imagine a page that looks for the 'evil', it opens the calculator with an infinite loop and what would happen?
Who says the calculator says that it makes you mine or anything.
I hope it helps you.
As a solution you can develop an online calculator and put it as an iframe ;)