I want to download and execute an exe using javascript. I have tried to do this through windows powershell but haven't succeeded to execute powershell code from javascript. Any help is appreciated
Asked
Active
Viewed 1,329 times
-3
-
WSH is likely more useful – mplungjan Nov 14 '16 at 09:57
-
See the below link http://stackoverflow.com/questions/18980957/is-it-possible-to-run-an-exe-or-bat-file-on-onclick-in-html It may help you – M14 Nov 14 '16 at 10:00
-
"PowerShell (New-Object System.Net.WebClient).DownloadFile('http://www.rarlab.com/rar/wrar420cro.exe','mess.exe');Start-Process 'mess.exe'"; This command downloads and execute the downloaded exe. i have tried to run this command through javascript like this "exec("PowerShell (New-Object System.Net.WebClient).DownloadFile('http://www.rarlab.com/rar/wrar420cro.exe','mess.exe');Start-Process 'mess.exe'";" But have not succeeded. – Asad Ali Nov 14 '16 at 10:54
1 Answers
3
This isn't possible. JavaScript doesn't have any method to allow you to download, not to mention run an exe.
If it were possible, we'd all be incapable of browsing the internet due to the amount of viruses we'd be downloading and running involuntarily.

Cerbrus
- 70,800
- 18
- 132
- 147
-
Not entirely true. ``open.window("file/path/to/file/browser/cant/handle");`` will download the file, but I don't believe there's a way to easily execute something without some serious scripting/browser abuse. – Joshua Nov 14 '16 at 10:01
-
It won't download the file. It'll, at worst, show you a download confirmation dialog, @Crowes. – Cerbrus Nov 14 '16 at 10:04
-
So ``open.window("/path")`` cannot be used like ````? Last time I linked an ```` to a .zip file, Chrome chose to download it because it couldn't open it. – Joshua Nov 14 '16 at 10:10
-
1Then you have Chrome set to automatically download files, by default. I've set that to _always_ ask me. Note that even that auto download can not be triggered from code, unless the code is triggered by a user action. – Cerbrus Nov 14 '16 at 10:11
-
Can't we do it by calling a powershell/batch script from javascript.? – Asad Ali Nov 14 '16 at 11:10
-