Solved

How to make an updater for my app?

Posted on 2001-07-29
9
136 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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:wileecoy
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:hveld
Comment Utility
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 100 total points
Comment Utility
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
Comment Utility
Do let me know if you need more help with your program or with winzip : )
0
 

Author Comment

by:hveld
Comment Utility
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
Comment Utility
Thanks! : )
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now