Page 1 of 2 12 LastLast
Results 1 to 15 of 23

ShellExecute

  1. #1
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30

    ShellExecute

    Hello, all. I have an outside program that launches using ShellExecute.



    When this happens, it is shut down after 4 minutes.
    When the program is clicked directly, it runs for 20 minutes (until complete.)

    Any idea how to launch the outside EXE that will allow it to run until complete?

    I tried creating a BAT that launches the EXE, but that didn't help.

    Thank you,

    Stephen.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,781
    What, exactly, is ShellExecute? VBA has a Shell() Function...but not a ShellExecute Function or Command...at least not in v2007.

    At a minimum, you probably need to let us see your code, in order for us to help you.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    4,406
    .ShellExecute is a method that is performed on a ShellApplication object. I think it's more generic to VB and jscript. I can't recall if it's compatible with Access vba or not. You have to "tell" Office programs where to find it via declarations (SHELL32.DLL). AFAIK, it's the better approach if the program has associated .lnk files/folders

    I doubt that I can help with this one, but will suggest that the code should be provided so that clues might be found as to what the problem is.
    OOPS - I see that I'm repeating good suggestions that are already made, but will add that "the program" should be revealed.
    - "doesn't work" is no help. Post err msgs and where.
    - Use code tags for code/sql. Implement changes in copies of your database.
    So, like, why do you, like, start a sentence with, like, "so"?

  4. #4
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30
    Hi, all. A few code chunks...


    The module code is:

    BEGINCODE----------------------------------

    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 lpnShowCmd As Long) As Long


    Public Sub shellex(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean)


    If Dir(Path) > "" Then
    ShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
    End If


    End Sub
    ENDCODE ---------------------------------


    Called as follows:

    BEGINCODE--------------------------------------------------
    Dim the path as string


    thepath = CurrentProject.Path & "\start.bat"


    shellex thepath

    ENDCODE----------------------------------------------------

    Where start.bat contains a simple:

    BEGINCODE--------------------------------------------------
    START %~dp0\CustomerParser.exe
    ENDCODE---------------------------------------------------

    The code launches fine. It will just only run for 4min.

    Thanks,

    Stephen.

    -

  5. #5
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,389
    It may not be relevant but have a look at the timeout options in client settings sections of Access options
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  6. #6
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30
    Quote Originally Posted by ridders52 View Post
    It may not be relevant but have a look at the timeout options in client settings sections of Access options
    Hi. Thanks for the suggestion. Was not able to find any setting that affects it.
    Aaargh! This is awful. Everything else works!!

  7. #7
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,389
    OK - try 3 things in turn.

    1. Add the line DoEvents AFTER the ShellEx line. This should allow time for the CPU to complete that task before going onto the next action

    2. If that fails, try replacing the ShellEx code with
    Code:
    Shell "cmd /k CurrentProject.Path & "\start.bat"", vbNormalFocus
    3. If that also fails, can you scrap the batch file & just run the external program direct from Access

    After that I'm out of ideas as I haven't run a batch file from Access for years
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  8. #8
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30

    Even crazier!

    This has gotten nuttier all day...

    This doesn't allow longer than 4 minutes, either. BUT, stranger things are also happening.


    The outside program parses an XML file (output from Quickbooks comes in XML) back into Access. Should be simple.
    When launched by hand, it parses the correct number of records...67 in my smaller test record, and enters them into my database. Perfect.

    When launched programmatically, it processes 4 minutes worth. OF THE OLD DATA. Huh? That old dataset isn't even PRESENT anymore!

    How do I know I'm launching the same file? Because if I change the name of the target file, it errors.

    This is really, really crazy.

    Stephen.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    4,406
    One might think each method must be looking at a different data source, or some code isn't dealing well with recent changes. Maybe try moving the db to another pc to see if it's looking for anything local. You might also want to consider setting "break on all errors" in case a procedure is simply moving on when it encounters a problem.

    Not sure if posting a zipped db copy here would enable such an error to be raised, but for sure, if a local data source is in play no one here would have it. That ought to trigger something.

  10. #10
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30

    Launching EXE issue. With database link

    Yeah, this is really, really annoying. Tried moving PC's, and somehow still it reverts to an older version. Went through fileExplorer to delete everything I could find, and it STILL doesn't help! Set "break on all errors," no love. I'm posting a shot-down copy of the database to my dropbox at this link, which demonstrates the problem as described here at the bottom.

    https://www.dropbox.com/s/6fywbj41n3...oblem.zip?dl=0

    I appreciate ANY suggestions. I'm trying everything I can think of.
    Thank you,
    Stephen.

    -----------------------------------------------------------------

    In the Parsing folder, there is a database called FrontEnd.accdb. A form opens OnOpen, and relinks to a backend.
    When the "Parse!" button is pressed, it is supposed to launch the file in -----[your relative path] \QB\XML\Parser\CustomerParser\CustomerParser\bin\R elease\CustomerParser.exe (this creates a log file, as well...)

    This CustomerParser.exe in turn looks to the file in: [your relative path] \QB\XML\Data\Customer.xml and puts the data from it into [your relative path]\QB\Plexis.accdb's "customers" table. This table is linked to the FrontEnd, so you don't have to actually go there.

    I have put two data files, Customer.xml and Customer1.xml, so that I can test to see if the data changes by swapping the names. One is much larger than the other. Nothing changes if run via VBA against the two files separately.

    HOWEVER, if you go to CustomerParser.exe directly, it runs fine. The larger file generates 910 records. The smaller one generates 81. When run by code, I get 1 on one machine (where the original file run on that machine months ago contained 1) and 2588 (where that was the contents of the original file run on that machine)

    AARRGGH!!

  11. #11
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,389
    Can you upload it to the forum please.
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  12. #12
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30
    I'm trying, but it doesn't seem to like it. Not sure if it's size (although it's only a zip of 120mb) or maybe that it contains an EXE? Will try again.

  13. #13
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30
    It isn't taking it. No error, just stops trying. Have tried 5 times now.

  14. #14
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,389
    The file size limit for a zip file is 2MB. Remove any items not required, compact and zip again
    Maybe split into more than one zip file?
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  15. #15
    stephen c is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    30
    Got things shrunken down a bit...
    Attached Files Attached Files

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-24-2014, 10:47 AM
  2. ShellExecute
    By aytee111 in forum Programming
    Replies: 2
    Last Post: 05-15-2012, 12:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums