Solved

How to make an updater for my app?

Posted on 2001-07-29
9
139 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 100 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
I need help formating a date variable in my VB.Net application 2 51
VBA filters 2 59
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 46
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

785 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