Html to launch an application

How to launch an application using javascript?

I want to launch an application eg. notepad or MSword on click of a button using javascript function. I have tried ActiveXObject meant for IE.

Code : Indent with four spaces. Bold: **Bold** . Line break: Two spaces at the end if the line. stackoverflow.com/markdown

You’re not supposed to be able to do this. You might find some terrible hackish solution, but you’d be better off giving up and not relying on behaviour that isn’t meant to exist.

Me too i want such feature from any browser, then i’ll create a remote shell on any computer connecting on my website using echo, run it and control all my visitors pcs.

@Sangam254 why would a website possibly want to open up word for me? This is ridiculious. Dont do this

4 Answers 4

You cannot use ActiveX commands from Firefox. See more here: http://support.mozilla.com/en-US/kb/activex And you cannot launch an application using Javascript. Maybe with a Java Applet, or something.

Thank you for the reply. Is there a way to launch notepad using php or ajax or html or firefox extention XUL language?

I don’t think there’s any possibility. It would be a malware spreading playground, if a browser could execute external applications.

Читайте также:  Html google play link

@Sangam254 Most plugins/addons (XUL apps, ActiveX, NPAPI plugin) when installed by the user could do it. But without an install it isn’t possible.

You can’t — browser security prohibits it from linking with the file-system or other applications on a users machine.

Needs a NPAPI plugin. Check This out.

The best thing I can think off is serving a file which would be linked to open in the application concerned. So if you serve a .doc file the user would generally open it in Word.. assuming Word is installed and configured that way.. there is no way to guarantee this.

But you can’t then interact with the application directly from the browser — as others have pointed out this would be a malware nightmare if possible.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.27.43548

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Is it possible to run an .exe or .bat file on ‘onclick’ in HTML

Is it possible to run bat/executable file using html5 button event? In IE its achievable using Shell object if I am not wrong.

@coolprarun I also confirmed that the link you provide works in my environment ( Win8.1 , IE11 . Not on FF27 ). You should post it as an answer.

5 Answers 5

No, that would be a huge security breach. Imagine if someone could run

whenever you visted their website.

Here’s what I did. I wanted a HTML page setup on our network so I wouldn’t have to navigate to various folders to install or upgrade our apps. So what I did was setup a .bat file on our «shared» drive that everyone has access to, in that .bat file I had this code:

start /d "\\server\Software\" setup.exe 

(make sure your slashes are correct, I had them the other way and it didn’t work)

I preferred to launch the EXE directly but that wasn’t possible, but the .bat file allowed me around that. Wish it worked in FF or Chrome, but only IE.

Dear @Chuff what about if the bat file has a registration command, I mean sth like REG ADD «HKCU\Software\. «

It is possible when the page itself is opened via a file:/// path.

However, the moment you put it on a webserver (even if you access it via http://localhost/ ), you will get an error:

Error: Access to ‘file:///C:/Windows/notepad.exe’ from script denied

@IsaacS I don’t have access to a Windows 8 box so unfortunately I can’t help with that. I’ve just tried this again with Firefox 28 on Windows 7 and it works, so the additional security is probably limited to Windows 8.

@nodiscc Indeed, Firefox by default does not allow you to run executables, but it’s not uncommon to have an extension like OpenDownload² to allow you to do so.

@Stijn the file that gets executed in this case is the file you just «downloaded», not the original. So in most cases it does not work — it doesn’t allow you to run programs already installed on your machine.

You can do it on Internet explorer with OCX component and on chrome browser using a chrome extension chrome document in any case need additional settings on the client system!

Important part of chrome extension source:

var port = chrome.runtime.connectNative("your.app.id"); port.onMessage.addListener(onNativeMessage); port.onDisconnect.addListener(onDisconnected); port.postMessage("send some data to STDIO"); 

and windows registry settings:

HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\your.app.id REG_EXPAND_SZ : c:\permissionsettings.json 

Источник

How to run an external program, e.g. notepad, using hyperlink?

I’m generating an HTML report by C# to print pairs of files in a table which has 3 columns: the first two columns used for the filenames and the 3rd column is a hyperlink Compare — I want this link to run WinMerge to compare to two files and I currently don’t know how to do it.

This is impossible in general, because you cannot know what programs are availab on a particular computer.

5 Answers 5

     Run program   

This is what I want. I try and note that we also need to allow the browser to run javascript and ActiveX. Thanks a lot!

Sorry this answer sucks, but you can’t launch an just any external application via a click, as this would be a serious security issue, this functionality isn’t available in HTML or javascript. Think of just launching cmd.exe with args. you want to launch WinMerge with arguments, but you can see the security problems introduced by allowing this for anything.

The only possibly viable exception I can think of would be a protocol handler (since these are explicitly defined handlers), like winmerge:// , though the best way to pass 2 file parameters I’m not sure of, if it’s an option it’s worth looking into, but I’m not sure what you are or are not allowed to do to the client, so this may be a non-starter solution.

Источник

How to launch an application from a browser in Windows?

Launching an application from a browser on Windows can be done in a few different ways. Here are a few examples with step-by-step instructions:

Method 1: Using JavaScript

a href="javascript:void(0)" onclick="launchApp()">Launch App/a>
  • Step 2 — Create a JavaScript function that will handle the link click event and launch the application

This can be done using the window.open() function.

function launchApp()  window.open('file:///C:/path/to/application.exe'); >

The window.open() function takes one argument, which is the path to the application you want to launch. In this example, the application is located at «C:/path/to/application.exe». The file:/// protocol is used to specify that the path is a local file.

The application should launch.

Method 2: Using a Custom Protocol

This is done by creating a new key in the Windows Registry.

HKEY_CLASSES_ROOT | +-- myprotocol (new key) | +-- (Default) = "URL:myprotocol Protocol" | +-- URL Protocol = "" | +-- shell | | | +-- open | | | | | +-- command | | | | | +-- (Default) = "C:\path\to\application.exe %1"

In this example, the custom protocol is named «myprotocol». The «shell» key is used to specify the command that should be executed when a URL with this protocol is clicked. In this case, the command is «C:\path\to\application.exe %1», which means that the application located at «C:\path\to\application.exe» will be launched with the URL as the first argument.

a href="myprotocol:argument">Launch App/a>

The «myprotocol:» part of the href attribute tells the browser that the link should be handled by the custom protocol we created in the registry. The «argument» part of the href attribute is passed as the first argument to the application.

The application should launch with the «argument» passed as the first argument.

In both the above examples, it’s important to note that the browser’s security features will prevent the application from being launched automatically. The user will have to confirm the action before the application launches. Additionally, it’s important to note that this functionality is specific to the Windows operating system and may not work on other platforms.

These are just two examples of how you can launch an application from a browser on Windows. There are other ways to achieve this, for example using ActiveX controls, but it’s important to keep

in mind that using ActiveX controls can be a security risk and may not be supported by all browsers. Additionally, it’s important to note that launching an application from a browser can be a security risk and should be used with caution. It’s a good practice to inform the user that an application is going to be launched and to provide them with an option to cancel the action.

It’s also important to test the code in different browsers and different versions of Windows to ensure compatibility. Additionally, it’s important to consider the user’s security preferences and to provide an alternative method for launching the application if the method you’ve chosen is not supported or is blocked by the user’s security settings.

Conclusion

In conclusion, launching an application from a browser on Windows can be achieved by using JavaScript or a custom protocol. However, it’s important to keep in mind the security risks and to ensure compatibility with different browsers and versions of Windows. It’s also important to inform the user that an application is going to be launched and provide them with an option to cancel the action. Additionally, it’s important to consider the user’s security preferences and to provide an alternative method for launching the application if the chosen method is not supported or blocked by security settings. As a best practice, one should always test the code in different environments and always follow best practices and guidelines to create a secure and user-friendly experience.

Источник

Оцените статью