I want to create JavaScript exe file. On clicking of exe file, It should open my reactJS web application in web browser.
From JS exe file, I have to pass query param to Web application.
Please help me with code.
You can create a shell script to launch the browser with a link to your web application that is on your local machine. You haven't given much details, but in general it's pretty easy.
cat > launch.exe
#!/bin/bash
$BROWSER http://localhost
chmod +x launch.exe
./launch.exe
If this is to be compiled and run on Windows installations only then here's your answer: https://msdn.microsoft.com/en-us/library/7435xtz6(v=vs.100).aspx
Java code is different from JavaScript. They might both be Object Oriented Programming (OOP), but JavaScript is specifically a scripting language. Its impossible to make a .exe file out of JavaScript.
You should try jsc.exe (under Windows only), NWJS or Electron.
The latest two are surely your best pick.
Edit: I would add NeutralinoJs to my previous suggestion.
It's nice, simple and useful.
Related
So, I'm making a quiz, and I've been wanting to save my answers to a text file. I want to use "Node.js", and I'm worried about this: They only offer an installer to install Node.js on your computer. Since I'm not working with servers or anything like that, and I'm just a hobbyist, the people I might first give this to may not have Node.js installed on their computer. Please do note that this is for a website, not a program.
Is this kind of thing possible to do without the use of a hosting service or a server? :
const lib = require('./libraries/NODE')
If it is, how would I do it?
Thanks for any help!
There are two options for you:
I would suggest using something like Electron- which will wrap the node runtime for you - https://www.electronjs.org/docs/tutorial/first-app which you can distribute to people. This will open up all the nodejs related functionality and more for you.
Another answer at SO though old, suggests using window.name vs writing out text files - Javascript/HTML Storage Options Under File Protocol (file://)
You cannot import nodejs runtime into the browser running on a file protocol.
Simply put, how do I compile/create and "exe" file that when you click on it, it will open console for you and type in the node "something"
There is a question about this regarding batch, but I really don't want to do anything batch because then you have to deal with filepaths, installing node... etc. Thank you for your help.
nexe says it will create a single executable out of your node.js apps.
https://github.com/nexe/nexe
You can boundle electron application
Write in html, css, js and distribute to any platform
http://electron.atom.io/docs/tutorial/application-distribution/
The title says it all. Is there a way to write macros in JavaScript to achieve a similar functionality to that of Autoit? I just would want to manipulate files on my own computer (offline) and could easily do it with autoit, but since I am currently learning JavaScript -- plan to develop in Node.js -- I figure it wouldn't hurt to get the extra practice.
Thanks guys!
Use an application which supports JavaScript as a shell scripting language, such as the following:
JsRoboKey
PowershellJS
PowerChakra
RemoteNodeJS
JScript + WSH
JavaScript Shell Scripting with JSC
QtScript: QScriptEngine
Part I: How to Choose a JavaScript Engine for iOS and Android Development - OpenAphid-Engine
nodejs has a module which do autoit things --
nodejs install autoit
var au = require('autoit');
au.Init();
au.Run("notepad.exe");
au.WinWait("[Class:Notepad]");
au.Send("Hello, autoit & nodejs!");
NodeJS is a very powerfull platform, it is extensible and opensource.
There is no problem to run local scripts to do everything you need using JavaScript (see standard FileSystem library docs). You can also try to look in NPM(NodeJS package manager).
Assuming you have AutoIt installed (say in folder C:\AU3) and this folder in the PATH, you can add
extension '.AU3' to the PATHEXT environment variable, and create an AutoIt script called, say,
hello.au3 with just a silly line:
MsgBox(0, "Warning", "Hello, World!")
Now, simply typing the command 'hello' will execute the script, displaying the silly message in a modal message box.
Next, create an equally silly Node.js script, say, MyWarn.js - in the same folder:
var oCP = require("child_process");
console.log("Starting...");
var oNP = oCP.execSync("hello");
console.log("Done.");
Assuming Node is also in the PATH, try this command:
node MyWarn
So ... we get the benefits of Node (for its jit), and the benefits of AutoIt (for its GUI handling.)
The problem is getting the two to communicate. Personally, I use a RamDisk to pass small files...
Javascript can't write to a file on your local machine remotely.. Its almost the same as HTML in a view model.
It can however perform some executions of other scripts via AJAX for example. But thats on server again.
It might be worth a look to read on server && client side differences.
im not 100% sure but node might offer another outlet on this but it would still be server side.. Not locally.
The Server - This party is responsible for serving pages and handling the logic | Code behind.
The Client - This party requests pages from the Server, and displays them to the user. On most cases, the client is a web browser.
The User - The user uses the Client in order to surf the web, fill in forms, watch videos online, etc.
Is it possible to list the files in a directory using only javascript? To clarify, I mean list the files on the server, not the files on the clients computer. For instance:
www.domain.com/files/
contains 4 images (.jpg)
Can I make an extra page (www.domain.com/files/list.html) that lists those 4 files using javascript?
No, Javascript doesn't have access to the filesystem. Server side Javascript is a whole different story but I guess you don't mean that.
Very late to this party, but my google search for this exact request led me here.
The answer is "not really", but I've found the frankenstein of hacks elsewhere: If +Indexes is (or can be) enabled in the .htaccess for the folder containing the files you want to list, then use XMLHTTPRequest with the folder name as the url (which will return an html page listing the files).
I don't know if you architecture allows it but ikf you can install and use node.js as its node API mentions, you can interact with the filesystem by requiring the fs module.
This is the environment Node.js relies on:
Node eventually wants to support all
POSIX operating systems (including
Windows with MinGW) but at the moment
it is only being tested on Linux,
Macintosh, and Solaris. The build
system requires Python 2.4 or better.
V8, on which Node is built, supports
only IA-32 and ARM processors. V8 is
included in the Node distribution. To
use TLS, OpenSSL are required. There
are no other dependencies.
You can run It side-by-side with another web app. and this will avoid blocking your web application if the interaction with the filesystem takes too long.
It is generally not a good idea to access client computer files via javascript for security reasons, however i suspect you can use the File System Object for that. I am not sure about browser-compatibility for that, it should work in IE only probably though.
You need to use server-side languages such as PHP, ASP.Net, JSP, etc
JavaScript runs inside a host environment. So if the host provides a facility to list files in this manner, then yes. But in the typical scenario where JavaScript is running in a browser with default configuration, no.
I started learning JavaScript a while ago. It's a fairly easy programming language considering that I learned Java in university, that I know php pretty well and that I already played around with python and ruby. The problem is that to properly learn a programming language I usually create a project. In javascript, I just don't know what kind of project I could create - that is, a project that is not web-based or related to the web browser. Can I create javascript shell scripts? Where is javascript commonly used beside the web browsers?
So, can someone actually give me some ideas please?
Can I create javascript shell scripts?
You bet!
On Windows, you can do this by using cscript.exe (you can even set up a file extension -- I use jx -- that automatically runs when you just double-click the filename or use it as a command in a shell: Just associate that file extension with the command "c:\WINDOWS\system32\cscript.exe" /e:JavaScript /nologo "%1" %*). This is (and I've measured carefully) about 80 milion times better than fighting with Windows' batch language. About. (And if you don't want to use JScript — Microsoft's variant of JavaScript — you even have options, see below.)
On *nix, a shell script can be set to run in any installed interpreter (that's what the #!... line at the top is telling the command interpreter). I expect you'll find a few if you search around.
On the Mac, you probably have JavaScriptCore installed in /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
And on all of the above, if you like, you can install Rhino and Java and get platform independence and access to a huge range of library functionality. Rhino has a built-in shell, or you can tell it to execute a specific JavaScript file. It interoperates with Java, so if you do this, you have easy access to all essentially of the functionality available to Java.
Where is javascript commonly used beside the web browsers?
I use it for shell scripting on Windows. I also use it as a server-side language, for instance in the server-side part of a web application. It's also used in other environments where a lightweight, powerful scripting language is useful, such as in the MongoDB shell environment (you can use it to query MongoDB data) and stored procedures.
All of that said, writing a browser-based project is a rich, interactive way to learn the language.
windows Sidebar Gadgets, Apple's Widgets, and Google Desktop Gadgets are all created using HTML/ JS/ CSS.
I learnt Javascript by creating a few small Windows Sidebar Gadgets.
Getting Started
Sidebar Reference
You could use javascript to make HTA (HTML Applications) that can be run outside of the the web browser sandbox. MSDN intro to HTA ApplicationsJavascript Tutorial on HTML Applications
You could write a non-blocking TCP server.
Node.js supports that.
Common uses of javascript outside of browsers are WSH scripts and HTA applications on Windows and Dashboard widgets on Mac.