Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to execute .exe programetically using java

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I need ur help in solving a problem.

I want to execute a .exe file which is downloaded(on my local drive) programettically.

The processes which I have to follow is :-
1.I have to download that executable from server to client machine(my machine).
2. Then after completion of downloading that executable should be executed automatically.

I will be very thanx full if you provide a code for this.

Thanx in advance
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you can download a file depends on how the server is accessible. Check the FileUpload page for hints on how to do this using HTTP, FTP and SMB.

As to how to execute an external program, check the Java Intermediate FAQ.
[ November 22, 2005: Message edited by: Ulf Dittmer ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Ulf describes (file upload), is for uploading files from a client to a server.

I guess you mean you want a client to download an EXE from the server and execute it.

That is not easily possible, and for good reason. It would be a huge security bug if it were possible to download and execute native code like that from a server, without any user intervention.

You could just put the exe on the server in a directory where the webserver software can access it, and include a link to it in your web application. When the user clicks the link, the browser will ask the user what to do with it: download it, run it etc.
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What Ulf describes (file upload), is for uploading files from a client to a server.



Actually, no, I am talking about download (don't be misled by the page name, the libraries all can do both upload and download). And it is very easily possible, although it is, as Jesper points out, quite a security risk. Be careful about which servers you connect to.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't that hard to do. Just download the file in to a temporary directory, and call the following API:

Runtime.getRuntime().exec ("FILE_PATH");
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic