CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Program Update

  1. #1
    Join Date
    Jan 2013
    Posts
    90

    Program Update

    We have the main executable file, let's call it MainProgram.exe. We also have Starter.exe file. Both are installed by setup package on the users workstations.
    The startup icon (shortcut) for Starter.exe is located on the desktop of the workstation.
    On the server we have MainProgram.exe
    The user should start Starter.exe by double clicking on the shortcut. This utility compares versions of MainProgram.exe files on the server and workstation.
    If they are different then Starter.exe replaces MainProgram.exe on the workstation with the version on the server.
    Everything works fine within many years.
    But by some reason some users make the shortcut to the MainProgram.exe and start the MainProgram.exe directly.
    It doesn't allow to update MainProgram.exe automatically.

    Any advice how to prevent direct start of MainProgram.exe please.

    Thank you.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Program Update

    I suppose you could check to see if the starter.exe is running when mainprogram.exe starts and if not then terminate the mainprogram.exe, Perhaps give the user a message or perhaps launch the starter program and terminate the mainprogram so starter exe can do its job.

    Another option may be to change the file extension of the mainprogram so that the system will not try to execute it if they click on it directly, setting its attribute to hidden may help as well.
    Always use [code][/code] tags when posting code.

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Program Update

    Does starter.exe start the program mainprogram.exe and then terminate?

    Another way to consider is that when starter starts mainprogram starter passes a particular set of chars as a command argument to mainprogram. mainprogram checks the command arguments and if this specific one isn't present then mainprogram starts starter and then terminates. This way it won't matter whether the user started starter or mainprogram - the effect would be the same.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    Jan 2013
    Posts
    90

    Re: Program Update

    Starter.exe starts MainProgram, but doesn't terminate it. It terminates itself after its actions - checking difference and replacement if needed.

    I will think about passing arguments. For now I do not know how it can be done.

    Thank you.

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Program Update

    I will think about passing arguments. For now I do not know how it can be done.
    For info about command line arguments see
    http://stackoverflow.com/questions/9...ommand-in-vb-6
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Program Update

    One way to do this is to use a named mutex that gets shared between the starter.exe and the mainprogram.exe.

    The starter.exe creates the named mutex, does its update check, updates if necessary and then fires off the mainprogram.exe. When the mainprogram.exe starts, it checks for the mutex and if it isn't there, it displays an error message to the user and then exits.

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

Featured