Execute Command (cmd) by Hyperlink or Javascript - javascript

I am looking for a way to make the client machine execute some command line in the command prompt (cmd) from a web page (intranet application).
I guess (and hope) this cannot be done by browser standards. But assuming I have full access to the clients' machines and can setup everything I need on them - Is there a way to make Internet Explorer trigger a launch of cmd and execute a given command? So I could then include hyperlinks or javascript to access it like, for example, this:
Click Me
executeCmd('C:\\Program Files\\...');
If there is no easy way to configure something like this, I'd be very thankful for workarounds or different approaches to trigger a command from a web page.

Instead of using
Click Me
executeCmd('C:\\Program Files\\...');
Use this
Click Me

Related

I am trying to use a locally hosted Django webserver's HTML button to execute a python script that's on my local machine and I'm stumped

So, I'm pretty new to Django, python, and javascript.
I have a partially functional Django webserver that, while developing it, I host locally on my machine.
I've made a button with HTML which I've figured out can be tied to a javascript script. The next step for me was to make this button "execute" a python script that's sitting on my machine, particularly on the /desktop directory. I can of course move the script though, but the important part is that I want that python script (let's call it django_test_script.py) to open its own window on my machine. It's just a file that says "hi" in stdout, then closes after 5 seconds, but due to the plan for this whole project, I want that to happen. I want to have my website open on my machine, click that button, then have the script's console pop up on my desktop and run/finish.
The eventual goal is to control an LED strip that's plugged into my raspberry pi. I want colored buttons on the website that, when clicked, run appropriate python scripts that turn the lights to that color. It wouldn't take me long to write up the python scripts themselves that would change colors, but I need to bridge the gap between "button causes a py script to run" and the python script actually running.
I see a ton of questions similar to this, but they all seem to involve running the python scripts WITHIN the webserver, like internal files that do everything and then return something to the server via an HttpResponse.
I don't need an HttpResponse. Literally all I want to do for right now is figure out how to make a script that's stored on the machine run.
I've done some reading on AJAX and I'm guessing that's involved, however everything I've tried has failed with AJAX in terms of actually getting the server to RUN a script. I've been scouring the internet for over an hour now and have found basically nothing useful (as far as I can tell) so I figured I may as well ask for help. Can someone please point me in the right direction in terms of what I'll need to do?
I'm afraid that's not possible. The browser doesn't allow to execute local scripts since everything is (for security reasons) in a sandbox.
If you want to execute something you could do one of the following:
Use a http server which executes the script and call it via AJAX
You build it into an exectron / nodejs app which opens more possibilities to access the system. See this example
But from your requirement I assume the website will be opened on another device to remote control the Pi led? If you you'll need to use some sort of http server as otherwise you can't run the script on the pi itself.

Call local PowerShell Script from Browser/Javascript

I know this is security-wise an absolute No-Go. But I have a customer, who has an angular application running internally only. This means the workers of the customer don't have internet access in the browser in which they use the application, and it is running in a virtual machine.
So they don't really care about browser-security, since they only use the application on it.
Now they have following use case:
User clicks a button in the Angular app
A powershell script on the local machine gets executed
So my question is, is there a way to call a local Powershell script with using Angular/Javascript?
My current idea
I could start a local NodeJS server on the virtual machines (always when they are booting) running on localhost:8080 for example, which listens for Rest calls.
When the user hits the button, the Angular app will make a Rest-Call to localhost:8080, which is the client node-server and the node-server executes the Powershell-script.
I see that's possible with: Execute Powershell script from Node.js
So does this make sense?
Or is there a better way to accomplish something like this? (As I said if there's a possibility to turn off browser security it's ok.)
Other way to achieve this is by registering a custom protocol with your application. That is how lot of apps like slack, skype etc work. But, your initial solution seems more platform independent.

how am I going to test my node.js code in the browser?

newbie here.
So I have this button, when a user click on that button, a node.js fs function will execute and will create a new folder for me, that is the fs.mkdir() function,
the code is just simple, and works on the terminal too, but I do not want to work in the terminal anymore I want to test on browser, I want to bind html elements to nodejs, I am so confused right now, when I open my html file it gives me an error : "require is not define", I search and search for hours. and I realize that most of the tutorials online they test and run the code in the terminal so how does someone test on browser to know if their code works?
to summarize my problem, I just want to interact on html elements, and that elements will cause to fire a node.js functions, how do I test it in the browser?
Node.js is used to run javascript on a node server. It runs server-side
The browser plays the role of a client
If you want to click a button in the browser and then execute a function in nodejs as a result of the click, you need to know that the architecture is a client-server
You'll need to setup a nodejs server, maybe using express.js, and then you'll need to do maybe a form in html that sends an http query from the browser to the server, so that the server executes the script you want.

IRC webclient on normal webserver

I want to set up a website which can do this:
The page itself should be blank or just a connect button.
While on the website I want to connect to an IRC server and listen for a specific command, which is given by a simple IRC message.
When receiving this command I want to play a short sound file that the command arrived.
This have to run in the webbrowser and should work on a normal webserver.
I already found something about node.js but this sounds like everything runs on the server itself, but this is what I don't want to have.
How can I do this? I know that I need javascript but I don't now where I could start.
I'd prefer some light open source projects I can modify a bit so there isn't much to do for me.

Running command prompt insite website

I want to run command prompt inside the website.
Actually I want to use Jemdoc in my website. Jemdoc generates an HTML website if you run in command prompt the command "jemdoc index". I want that when you click a button! I dont know how to program in PHP or c#.
Can I do that in JavaScript?
If you could give me an example will be great (JavaScript or not)!!!
the Browser can not execute arbitrary commands on the clients system for very good reasons.
In short, you need a server for this! This can be PHP, Java, NodeJS or whatever. Your website sends a trigger (ie HTTP-POST) to the Server and it executes jemdoc (also installed on the server) for you and updates the html documents.
Greets

Categories