• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to execute .exe programetically using java

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic