Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to run an .exe file present on my desktop using only javascript code in an ide.
Posted

I assume you are talking about JavaScript as part of a web page inside a browser...
It is not possible and for good reasons! JavaScript itself has no IO capabilities and web page runs inside a browser in what they called 'sandbox' - an isolated environment...
All this for improved security - you, after all, do not want that every site you visit will be able to run any executable on your computer when wishes so...
 
Share this answer
 
Comments
Abhi Ram S 27-Apr-15 4:02am    
Hi Peter,
Thanks for your answer, but i want to run exe using javascript ,but not as a part of a web page.
Kornfeld Eliyahu Peter 27-Apr-15 4:04am    
So what is your platform? What JS engine do you use? How do you intend to run the JS at the first place?
Abhi Ram S 27-Apr-15 4:20am    
Am using webstorm ide along with node.js.

var a = new ActiveXObject("WScript.Shell");
a.Run("C:\\Users\\Admin\\Desktop\\click.exe");

am getting error as ActiveXObject is not defined. Is there any way to run exe file or .bat files without using ActiveXObject..?

win 7.
Kornfeld Eliyahu Peter 27-Apr-15 4:28am    
Using node.js you may check this: https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback
Abhi Ram S 27-Apr-15 6:05am    
Thanks peter it worked.Thanks a lot
It depends on the limitation of the VM being using to execute your javascript. Browser VM's are sandboxed.

But if you use Node.js to run your code. This does allow you to launch processes:

http://stackoverflow.com/questions/5775088/is-it-possible-to-execute-an-external-program-from-within-node-js[^]
 
Share this answer
 
Comments
Abhi Ram S 27-Apr-15 4:22am    
Thanks Stephen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900