Results 1 to 5 of 5

Thread: How to automatically update application version

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    2

    How to automatically update application version

    Hi all!
    I've a little problem that arose up using a VB6 app under Vista/7
    In XP, I set up an update process with the following steps.
    1) application checks for update on server
    2) if new version available, running application launches a child application (shell) , transfers control to it and then quits.
    3) child application waits for a button press and then provides to copy new application program on app.path folder.
    4) Then, after copy is completed, child application launches new version under \program files folder and then quits itself.

    Under Windows XP, this process runs 'with flying colors' and it's well controlled.
    Under Vista, instead, I've got a lot of problem and errors.
    I googled around for some hints, but I've found only about some generi reccomendation to not use \program files folder for .ini and data files, and to use "runas" instead of shell.
    Has anyone already solved this problem, even adopting different processes, that can suggest me any solutions?

    Thanks in advance.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to automatically update application version

    Welcome to VBForums

    First of all, not storing data files in \program files isn't just a recommendation, since VB6 came out it has been the "rules" for Windows. For more information, see the article Where should I store the files that my program uses/creates? from our Classic VB FAQs (in the FAQ forum)


    To do the "runas", add this to your Declarations:
    Code:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
         (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
          ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOWNORMAL = 1
    ..and then use code like this:
    Code:
    ShellExecute 0, "runas", "c:\program files\filename.exe", vbNullString, vbNullString, SW_SHOWNORMAL
    On Vista this shows the normal UAC security prompt, but I'm not sure what effects it has on XP and earlier (note that it may differ based on whether the user is an Admin user or Limited user).

  3. #3
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: How to automatically update application version

    Went thru this about a yr ago.
    use SHGetFolderPath to get the path to CSIDL_COMMON_DOCUMENTS
    Put any data file there, put your exe in program files\yourname\your exe
    From sub Main my app looks to see if data files exist in app.path
    If DataFilesNotFound then
    gMyPath = CSIDL_COMMON_DOCUMENTS &" \YourCompany"
    else
    gMyPath = APP.Path
    Go thru your app and replace all the App.paths. with a global path eg:gMyPath
    be sure your installer has a manifest to install as Admin
    If you want you exe not have to run as admin the provide a manifest with you exe to run as "Invoker"
    Your program updater will require your app to run as admin. Provide a dialog using
    Private Declare Function IsUserAnAdmin Lib "shell32" () As Long
    if user is not Admin
    MsgBox "You must open the app as admin to do program updates"
    I have similar program updater :
    http://www.planet-source-code.com/vb...xtCodeId=69060
    this updater works good on vista as i have a customer that bought a new pc with vista and has found every little bug and has updated his exe about 10 times. I have even provided a hot key that will update the exe even if the online version is lower. A lot of little things in vista need modifaction: Eg Balloon tooltips do not always fit inside the ball0on properly. etc, etc
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2009
    Posts
    2

    Re: How to automatically update application version

    Many tnx to all.
    I suppose I've to recode my app and release a new major version.
    Is it possible to check what kind of OS is running?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to automatically update application version

    It is possible to check, but there is almost certainly no reason to - the folder methods work for Windows 2000 and later (and probably for earlier versions too).

    If you are thinking about the location of existing documents, rather than use a dodgy hack (the OS version is definitely not a safe way to check which locations are usable), you should fix the existing mistake you have made - which will give several benefits, such as enabling use of the "Transfer Wizard" built in to Windows.

    The method that isnoend07 described is a good way to fix it: when your program starts check if the proper data folder exists - if not, create it and copy all the data files to it.


    I'm not sure about the RunAs, but you should check on XP yourself (as Admin and non-Admin) to see what effect it has. If needed then do an apt check, which is likely to be something different to OS (perhaps user rights).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width