Open an external program

I'm currently working on a local web application and I want to be able to trigger an external application using a button click. I came across this code that works perfectly in an .html file with Internet Explorer, but when I try to implement it within a show.html.erb file, it throws an error message instead.

<script language="javascript">
function LaunchApp(appPath)
{
    try
    { 
        WSH = new ActiveXObject("WScript.Shell");
        WSH.run(appPath);
    }
    catch (ex)
    {
        errMsg = "An error occured while launching the application.\n\n";
        alert(errMsg);
    }
    window.open('', '_self', '');
}
</script>
<button onclick="LaunchApp('C:\\windows\\system32\\notepad.exe')">Click me</button>

Is there a way to successfully launch the external application from within this setup?

Answer №1

What do you think of the following code snippet?

function StartApplication(path)
  var shellObj = new ActiveXObject("Shell.Application");
  var command = path; 
  shellObj.ShellExecute(command, "", "", "open", "1");
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporate a fresh button into the Tinymce toolbar using C# programming

I have utilized Tinymce text editor/textarea in my webpage. How can I incorporate an additional button onto the toolbar? For instance, upon clicking the added button, it should prompt a dialog with three textfields: title, age, and gender. Upon filling ou ...

What is the most efficient method for designing this jQuery code to be reusable?

I am currently using dynamic Bootstrap popovers that are populated with content from my database. In PHP, it generates unique classes for each popover. My question is, when using jQuery, do I need to trigger the popovers individually? This is how I am cur ...

Send the user to a customized dashboard depending on their user role permissions using Vue.js

Currently, I am developing a system that involves handling multiple role-permissions for users. To provide some context, there are 3 distinct users in this scenario: User1 (customer), User2 (employee), and User3 (admin). For each of these user types, I ha ...

Can you list out the various settings attributes that can be used in the addButton() function of TinyMCE?

The guide is lacking clarity on this topic. name - String - The name of the button to be added. settings - Object - Object containing settings such as title, cmd, and more. What exactly does "etc" refer to? Is there a comprehensive list of all available ...

contrasting the application of logic in Rails controllers versus JavaScript within the .js.erb files

When dealing with a large "data" active record object that needs to be filtered based on user interactions on a page, the question arises about where to place the data-filtering logic. Currently, the filtering is done in the rails controller action, simpli ...

Node's MongoDB client

Currently tackling the challenge of connecting MongoDB in Node.js and passing the link to the client as an outer variable. I am looking to develop a module that can yield the result of the .find() method. How should I proceed with this? const MongoClient ...

Help setting up Angular ng-class is needed

Hey there, I'm currently attempting to change the background color of my CSS based on the value of ng-class (true or false). Can someone help me out with this? <div id="home"> Summoner <div id="in ...

Choose a list in order to create a new list

If I were to choose a specific state in Nigeria, what steps should I follow to generate a drop-down menu with a list of local governments within that state? ...

The value retrieved by JQuery attr remains constant

Hey everyone, I'm having an issue with getting the ID from a custom attribute using jQuery. When I try to debug, I keep getting the same value each time. I have an HTML table that lists posts from a database using PHP, each with its own specific ID. ...

Issue with compatibility between Capybara, Selenium, and ChromeDriver versions causing

Previously, I was able to successfully write system tests using Capybara for an old Rails project. However, when attempting to update the project following instructions from this solution and Chrome version 114.0.5735.90-1, a new version of Chrome had been ...

What is the best method for gracefully opening external links in a reusable new tab?

Here is the progress I have made so far: <script> var win; function OpenInNewTab(url ) { // var win; if (win) { win.close(); } win =window.open(url, 'myWin'); win.focus(); } </script> My links are structured like ...

Tips for updating nested data in mongoose with 2 unique identifiers?

Is there anyone out there with experience in making a Node push function work on nested objects beyond just one level? I'm looking to delve deeper into a second id within the DB model. // Functional code for updating a user at one level with one id ...

Tips on adjusting the pixel dimensions of an image using a file object

Within a form on our website, users have the ability to upload an image file. To ensure quality control, I've set up validation to confirm that the uploaded file is either an image or gif format. In addition to this, I'm looking for a solution th ...

Utilizing the raycaster.intersectObject in three.js to target and manipulate the descendants of an Object3

I have been exploring ways to create a series of clickable cubes that can be highlighted, allowing for color changes, texture additions, or other manipulations. After reviewing the source code of various interactive examples on , I noticed that each exampl ...

Tips for executing a join query in CodeIgniter

Hello, I am brand new to the CodeNighter framework and could really use some guidance on how to convert this join query into CodeNighter framework. Additionally, I need to know whether this join query should be placed in the model or controller. How can I ...

Issue with onclick event not firing properly following ASP.net AJAX save operation

I've encountered a puzzling issue with my gridview. I've successfully added onclick events to a checkbox column using the code: cb.InputAttributes.Add("onclick", "checkClick()"); Everything was working perfectly until the mom ...

Adding or removing a class using Jquery based on the condition of form validation

I am facing a problem with the following code that adds and removes classes to bring the next stage of the form. The form progresses step by step where certain fields need to be filled before validation on the next button, followed by filling other fields. ...

Two-way binding does not function properly with custom directives on Internet Explorer version 9

Take a look at this unique angular application : <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script> <link href="style.css" rel="stylesheet" /> &l ...

Check and uncheck checkboxes in a hierarchical structure in real-time

I am facing a similar question to a previously solved issue regarding unchecking parent nodes if all children are unchecked using JQuery, but I am attempting to enhance the solution by ensuring that the children will also all uncheck if the parent is unche ...

PHP can display content directly in the browser, without the need for jQuery

As I develop a web interface for an application that has longer processing times, a loading page is displayed to the user when it starts. An AJAX call then loads the output onto the page. Strangely, while browsing the PHP function directly in the browser r ...