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
Solved

Create an upgrade routine

Posted on 2008-10-31
2
319 Views
Last Modified: 2013-11-27
Hello,

I need to create a routine to upgrade my application.
When the user run the application it checks on the db if the actual version is the latest one. If it doesn't than a message box ask to the user: "A newer version is available. Do you want to install it?".
If the user confirm a .BAT file is run that deletes the .exe and copies from the server the actual version.

Tha problem is that the .bat can't delete the file because it is running (The process cannot access the file because it is being used by another process.). I need to "say" to my application to close himself and run the .BAT but I don't know how.

Any idea?

Thanks
Inside Main routine:
 
    If goApp.Version > goUtl.TranslateVer(sAppVersion) Then
        If MsgBox("A newer version is available. & vbCr & _
                    "Do you want to install it now?", vbYesNo Or vbInformation, "New Version available") = vbYes Then
            ' User selected Yes
            If InstallLastVersion = True Then
                MsgBox "Installation completed." & vbCr & "Please restart the application.", vbInformation, "Installation complete"
            Else
                MsgBox "Errore during installation." & vbCr & "Please contact your administrator.", vbCritical, "Error"
            End If
        End If
 
----------------------------------------
 
Public Function InstallLastVersion() As Boolean
 
Dim shell
On Error GoTo ErrorHandler
 
    Set shell = CreateObject("wscript.shell")
    shell.run App.path & "\UpgradeXps.bat"
    InstallLastVersion = True
 
ErrorCleanUp:
   On Error Resume Next
   ' cleaning variables
    Set shell = Nothing
   On Error GoTo 0
   Exit Function
ErrorHandler:
    InstallLastVersion = False
    Resume ErrorCleanUp
End Function
 
--------------------------
 
UpgradeXPS.bat file:
 
ECHO OFF
DEL /q d:\std\xps.exe
d:
CD \STD\XPS
copy \\servername\std\XPS.exe 
 
-----------------------------

Open in new window

0
Comment
Question by:webluca
2 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 500 total points
ID: 22850283
It's not very elegant but you can close the application by ending it's process, if you know its name:

Public Function EndProcess(sProcessName As String) As Boolean
Dim winProcess
    For Each winProcess In GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process")
        If LCase(winProcess.Name) = LCase(sProcessName) Then
            winProcess.Terminate
            EndProcess = True
            Exit For
        End If
    Next
End Function

Note: This will only work from an executable or script, not from the VB IDE.
0
 

Author Closing Comment

by:webluca
ID: 31512030
Thanks for the idea.
I Modified the .bat file adding TASKKILL /F /IM "application_name.exe"
before deleting the application.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Microsoft Access combo box help 2 50
Visual Studio: built-in keystroke automation 2 71
What namespace do I need to import? 2 38
which modules are active in VB6 project? 6 42
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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 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