how can i run this script in html? - html

I create a b.js script file like below. when i run this using node.exe program then it correctly open "word2code.exe" file.
How can i add this script in a .html page (as link or button onclick event) in appjs for windows?
var exec = require('child_process').execFile;
var fun =function(){
console.log("fun() start");
exec('word2code.exe', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();

You cannot run an exe directly on the client side in an HTML page -- the browser cannot understand binaries. Instead, if you basically want to fire off a process like this, you could take another approach:
Build a website that has a button.
This button, when clicked, should make a request to your server on some URL (like /execute).
Write a separate web server process on your windows machine, that runs the web server.
Write a route on your web server that handles /execute requests.
Make this route run your exe file LOCALLY ON YOUR SERVER when the route is executed.
By doing things this way, you're essentially allowing a web user to run an exe indirectly (your server will be the one running the binary, not the user).

Node.js runs on the server. The browser is on the client side. You cannot execute a nodejs app from the browser as the environment does not support nodejs.

Related

Need some agent to index/search remote file for Remote development

I have pretty heavy project to run locally on my notebook, and it runs on my local server machine. But i want to work with it from my notebook, locally without any screen sharing tool. I've tried to establish sftp connection with server and opened the project with PhpStorm, but it's terrifically slow..
Must say, that loading the files, saving, debugging - rather fast, but search and indexing (MOSTLY INDEXING) very slow. Maybe, is there any phpstorm agent for remote servers, that indexes on host, and sends via network summary data to my local PhpStorm application?
Or, maybe another tool with such remote agent. Like Atom plugins, Sublime.. or whatever?
There are no indexing agents for remote project accessing. It's recommended to work with locally stored project files with JetBrains IDEs.
You need to create 2 copies of source code the project.
One on your workstation, the second on your laptop.
After it, you can write a little script, which would watch your directory on the laptop and copy it to the workstation.
I use chokidar from npm (https://github.com/paulmillr/chokidar)
Code example:
const chokidar = require('chokidar');
var exec = require('child_process').exec;
chokidar.watch('repository', {ignored: /(^|[\/\\])\../}).on('all', (event, path) => {
if (event === 'change') {
console.log(event, path);
exec('scp "' + path + '" "${PATH_TO_WORKSTATION_PROJECT}' + path + '"',
function(err, stdout, stderr) {
if (err) {
console.log(err);
}
console.log(stdout);
});
}
});
Also you would need to configure remote debugging (but it's another topic)

Testing local website with Protractor

I am developing simple website (html, css) and I want to write few tests against it in Protractor.
Is it possible to check that kind of website with Protractor? I have html file on my computer only. Should I run this website locally on server? I don't think I can run test on file directly.
Yes, its possible to open a stand-alone local html file without hosting it on a local server.You have to add this browser.resetUrl = "file:///"in your onPrepare() function and then a browser.get("file:///C:/Users/demo/test.html") would work
There are some good examples #this question - Opening a file with protractor
A common way to do it is to approach it in multiple steps:
build your application
run a local web server from the build directory (I think this is the part you are asking about)
run tests against your app served by the local web server
stop the local web server
Usually, this multi-step process is handled by a task runner like grunt or gulp. We use grunt, grunt-contrib-connect to serve from a directory, grunt-protractor-runner to run protractor from grunt.

How to run local program (exe) via Chrome via HTML/javascript

I am trying to build a (single page) local portal in Chrome that opens several things.
The problem is we want to run a local executable via a button on a (local) webpage. Is this possible?
The second thing is that i want to do is to run a .pps file directly in the powerpoint viewer.
I can control to the startup of chrome, so i can access local files.
All things i tried so far only made the file(s) to download, not to run.
Can somebody help me how i get this done?
You can set a protocol like myapp://launch/activity or the like to automatically launch your app by setting up a registry key in HKEY_CLASSES_ROOT with the name of your protocol and the action it should take.
There is a MSDN article showing the following example of a registry for an alert protocol:
HKEY_CLASSES_ROOT
alert
(Default) = "URL:Alert Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "alert.exe,1"
shell
open
command
(Default) = "C:\Program Files\Alert\alert.exe" "%1"
Which would then be called by requesting a url with alert:YOURPARAMS, which would then call alert.exe YOURPARAMS.

Run .bat file from a webpage

I'm looking to find a way on how to start a .bat file from a webpage. This bat file just start a server.
My intention is to create a basic html page showing "Start server" and "Close Server".
Is there a way to do so? I was thinking to do it by an FTP server using HTML but it didn't helped me.
Thanks
With a static page would be difficult but for example using php :
<?php
exec('c:\myfile.bat');
?>
If you donĀ“t want execute the .bat locally you will execute a shell script (.sh) that executes remotely the batch file.
https://superuser.com/questions/292818/run-a-shell-script-with-an-html-button
You need to call cgi script for this action with proper access to start your services. Html doesn't have any access in server side. It can only trigger the request.
Put 2 files in your web folder:
Static html showing your bottoms
A PHP file to call the batch.
Just remember to install PHP on your IIS

Activate liveReload monitoring chrome-extension in google chrome launching from bash

I'm trying to develope a bash script that launches google-chrome with a installed extension called LiveReload, which is used to monitor web changes. The point is when a web page is open you have to trigger LiveReload to start monitoring, and I want to do that automatically.
Is it possible?
The most straightforward way is just to embed the livereload.js script directly in your page(s) during development:
<script src="js/vendor/livereload.js?host=localhost&port=32579"></script>
If you leave out the host and port params, LiveReload will infer them from the src attribute of the script tag. If you add the query param LR-verbose to the URL of your page (not the livereload.js tag), LiveReload will dump useful debugging info to the console attached to your page. E.g., http://localhost:8080/nextbigthing/ideas.html?LR-verbose
Since you're just manually loading the same file that the LiveReload extension would (either from its internal fallback copy, or from your LiveReload server), this behaves just as if you'd clicked the browser action button.