Solved

How to update executable file in same VS solution

Posted on 2006-11-30
6
170 Views
Last Modified: 2010-04-23
In a VS .Net 2003 solution I have a project called «App1».

From this project «App1» I can download an updated version of the exe called «App1_UPDATED.exe», put it in the same folder as «App1» and close the application.

Question:
Next time I start this VS .Net 2003 solution, I would like to check if there is a file called «App1_UPDATED.exe», and if so, delete «App1.exe», rename «App1_UPDATED.exe» to «App1.exe» and launch the newly updated «App1.exe».

What would be the best way ?

scml
0
Comment
Question by:scml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 125 total points
ID: 18049349
Hi scml,

If I understand you correctly, you could do the following in your application startup code:

        Dim pathToAppUpdated As String = "c:\somepath\app_updated.exe"
        Dim pathToApp As String = "c:\somepath\app.exe"
        If IO.File.Exists(pathToAppUpdated) Then
            IO.File.Delete(pathToApp)
            IO.File.Copy(pathToAppUpdated, pathToApp)
            IO.File.Delete(pathToAppUpdated)
        End If

Cheers,
Hillwaaa
0
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 18049374
Why do you want to do this? each time you build the app1 project it will overwrite the app1.exe file.
0
 
LVL 15

Expert Comment

by:Solar_Flare
ID: 18049381
sorry i misunderstood. disregard that last comment.
0
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 125 total points
ID: 18049425
to do what you want you will need to use a separate application, as your application will not be able to remove/update itself. The process app1.exe cannot be running when you try to do it otherwise you will get an error.


you could create a startup application called something like "start.exe" which checks to see if an updated version exists then starts the application

dim path as string = application.startuppath
if system.io.file.exists(path & "\app1_updated.exe") then
     IO.File.Move(path & "\app1_updated.exe", path & "\app1.exe")
end if

'now run the application
system.diagnostics.process.start(path & "\app1.exe")

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question