Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004

    Unanswered: Using Shell to Run an Executable

    Happy New Year, all!

    My database checks a version number at startup. If the front-end is older than the version number in the back-end, it not only closes but offers to run the installation file that updates the user's F-E.

    Here's basically the code I use, without all the specific message boxes.

    Version = DLookup("Version", "_Version")
    If CCur(Me.txtVersion) < Version Then
        Title = "Older Version"
        Prompt = "You're using an older database front-end version." & _
        "@Do you want to run the install file now?@"
        intAnswer = FormattedMsgBox(Prompt, vbYesNo + vbCritical, Title)
        If intAnswer = vbYes Then
            Title = "Opening File"
            Prompt = "This database will now close and the installation program " & _
            "will run."
            FormattedMsgBox Prompt, vbOKOnly + vbInformation, Title
            dblFileSuccess = Shell("M:\ProductionDatabaseSetup.exe", vbNormalFocus)
        ElseIf intAnswer = vbNo Then
            Title = "Closing"
            Prompt = "The upgrade is necessary to run this program." & _
            "@This program will now exit.@"
            FormattedMsgBox Prompt, vbCritical + vbOKOnly, Title
        End If
        Cancel = True
    End If
    Exit Sub
    Debug.Print Err.Number & Err.Description
    Title = "Error Opening Setup File"
    Prompt = "There was an error in opening the setup file."
    FormattedMsgBox Prompt, vbCritical + vbOKOnly, Title
    End Sub
    Does anyone see any harm in this? This is my first time using Shell to do this. If there's an easier way or better way, let me know. I'd greatly appreciate it! I'm basically worried about causing crashes, etc. I know that Shell returns a value for the status of the program. If it doesn't open, it'll give an error. Any help would be gladly received! Thanks!

    The teachings of God's Begotten: 2 John 1:9

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    I created a simple batch file to perform the "update" which I instruct the user to run, the I force the app closed. I think that's the easiest, safest way to do it. We also have a few applications that get versioned frequently, so we can update all of them in one fell swoop by adding a line or two to the batch file.

    Personal preference though, so long as you control your exe with file handles to ensure you're not trying to overwrite an open version, you should be fine. Also, if you're using 2k+, you can use the FSO to find the creation date for a given file, that's what I like to use to discern which is newer.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Sep 2004
    Tampa, FL
    Glad to hear I am not the only one using a gold old DOS batch file.

Posting Permissions

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