Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to make an updater for my app?

Posted on 2001-07-29
9
Medium Priority
?
149 Views
Last Modified: 2010-05-02
Hi,
I want to make an updater for my app so that people don't have to download the entire new version when one is released.
There is only one file which has to be replaced to update the app.
If the app is currently installed in c:\Program Files\MyApp\, I want to replace a file named main.exe inside that folder with a new one.
But I want to check first whether the app is registered. If yes, to replace main.exe with some file, and if not, to replace it with another file.
What I don't know is how to embed the files which should replace the old file(main.exe) in a single vb executable.
To be more precise, I want to embed in a single vb .exe 2 files, like 1.exe and 2.exe
When the vb exe is started, it will check whether the app is registered - if yes, it will replace main.exe with 1.exe. If not, it will replace it with 2.exe.
But I don't want users of the unregistered version to be able to get 1.exe
I hope I explained what i need clearly, thanks
0
Comment
Question by:hveld
[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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:wileecoy
ID: 6332844
I know this is a work-around, but you could use the shell function.

ex:

your file is called 1.exe.  You rename it to 1.qwe or 1.wer, or 1.anything.  Then you run it as.

shell app.path & "1.anything"

This will run it as an exe even though it isn't an exe.  And the user will not be as likely to know that it is an exe and that they can run it if they change the extension to exe.

hth.
0
 
LVL 1

Expert Comment

by:LuckyPhill
ID: 6332987
write a "pack process" executable that appends the new exe file /zip whatever to an updater program at a fixed byte address past the executable code.

when the updater runs it reads the update from itself and installs it in the correct place, its handy to include a listen socket in your app so that the updater can close it down via a sockets call smoothly, also make a registry entry to tell the updater where the app.path lives!!...

Packer code example:

DefInt A-Z
Global Const EXE_OFFSET& = 90& * 1024&

Type VersionType
  size As Long
  Version As String * 10
  buildTime As Date
End Type
Dim m_t As VersionType


Sub Main()
   fpout = FreeFile
   Open "F:\Projects\AMPartsShare2\UpgradeDistribution\Server\AMIPSServerUpgrade" & Command$ & ".exe" For Binary Access Read Write As fpout
   fpin = FreeFile
   Open "F:\Projects\AMPartsShare2\UpgradeDistribution\Server\wam.exe" For Binary Access Read As fpin
   m_t.size = LOF(fpin)
   m_t.Version = Command
   m_t.buildTime = Now
   
   Seek fpout, EXE_OFFSET&
   Put fpout, , m_t
   
   L& = LOF(fpin)
   upto& = 0&
   chunk& = 100
   While upto& < L&
     If L& - upto& < chunk& Then
        thisun& = L& - upto&
     Else
        thisun& = chunk&
     End If
     a$ = Space$(thisun&)
     Get #fpin, , a$
     Put #fpout, , a$
     upto& = upto& + thisun&
   Wend
   
   Close fpout
   Close fpin
End Sub


segment of Updater code:

DefInt A-Z
Global Const EXE_OFFSET& = 90& * 1024&

Type VersionType
  size As Long
  Version As String * 10
  buildTime As Date
End Type
Dim m_t As VersionType

Function UnPackExe() As Boolean
  Dim xtimer As Double, i As Integer, fpin As Integer, fpout As Integer
  Dim L&, upto&, chunk&, thisun&, a$
 
  fpin = FreeFile
  Open App.Path & "\" & App.EXEName & ".exe" For Binary Access Read As fpin
 
  fpout = FreeFile
 
  kill theAppYouWantToOverwrite
  Open theAppYouWantToOverwrite For Binary Access Write As fpout
  Seek fpin, EXE_OFFSET&
   
  ' get version info. use it to show the user build times /version etc...
  Get fpin, , m_t
 
  ' create the self expanding archive file
  L& = m_t.size
  upto& = 0&
  chunk& = 100
  While upto& < L&
    If L& - upto& < chunk& Then
       thisun& = L& - upto&
    Else
       thisun& = chunk&
    End If
    a$ = Space$(thisun&)
    Get #fpin, , a$
    Put #fpout, , a$
    upto& = upto& + thisun&
  Wend
  Close fpin
  Close fpout

...
0
 
LVL 1

Expert Comment

by:LuckyPhill
ID: 6332990
Ps.. this was taken from a live retail app we manufacture... so the technique works WELL, and only ONE file need be distributed for each release.

LuckyPhil
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Expert Comment

by:glass_cookie
ID: 6333064
Hi!

This is another alternative:

Create an OLE object and select packager as it's OLE type.

Craete a self-extracting exe file that zips your desired EXE file which unzips and overwrites automatically without alerting the user.

Then, import that self-extracting EXE file that you want in to that object and update it by closing the packager window.

Do the same for any other files that you want to import into your updater form.

Should any of the above conditions be met, then simply activate the correct OLE object to overwrite whatever files you want to update.

This is the code to run the ole object (ie. the self-extracting EXE) automatically (do remember to hide the controls too by setting OLEX.Top=-1000):

OLEX.Doverb (if the desired OLE control to activate is OLEX).

That's it!

glass cookie : )
0
 

Author Comment

by:hveld
ID: 6338614
LuckyPhil,thanks, I guess what you suggest could do the job but this is simply too advanced for me, I just can't understand it.
glass cookie, I tried your solution, but this way the file is extracted to the temp folder(with a different name each time I run the updater, like PKGxx.extension) , then the updater tries to execute it.
If I create a self extracting file(tried with winrar), it either prompts where to extract itself or extracts in a subfolder of the temp folder(also with a different name each time)
Is it possible to make something so that olex.doverb will simply extract the file to temp folder(or to folder of my choice) without trying to execute it?
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 400 total points
ID: 6340240
Hi!

Well, I use winzip - that's why I didn't mention anything about prompt messages.

Why not give Winzip a try - you could choose to ovewrite a file if it exists without it prompting you.  Moreover, you could specify the folder to which the files would be exracted to.  This feature is in the winzip self-extractor.

To download winzip, go to this site:
http://www.winzip.com

Zip up whatever files you want, then use the winzip self-extractor (you'll have to download it at the same site as a seperate component) to create the auto-self extracting file.  That option wil come as you follow the instructions/prompts along the way.

Meanwhile... I can't really think of an alternative solution as I'm experiencing some brain freeze: c++ exams for 'A' levels coursework starts tomorrow for me : |  I'll think about it after the test tomorrow.

That's it!

glass cookie : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6340245
Do let me know if you need more help with your program or with winzip : )
0
 

Author Comment

by:hveld
ID: 6340635
i did it with winrar after playing a bit with configs
Thanx!
And luck at the exams :)
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6342968
Thanks! : )
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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