Results 1 to 5 of 5
  1. #1
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72

    calling bat from VBA

    Hi, all. I have a set of JAR files that perform various functions for me. I call them by clicking a BAT file. I would like to have Access call these programs, based on some logic, but am having difficulty with the basics of launching the JAR via BAT from VBA. Here is what I have:

    Shell ("C:\ProgramData\Parsimony\A\D\FMP1\run.bat")



    Preeeeetty simple. I have repeatedly checked the path, and it is correct. I've copied it form "properties" just to be sure. What happens is a cmd window appears to open very quickly (barely see it) and then a whole lot of nothing. Doubleclicking run.bat executes the program just fine.

    Any ideas?

    Thanks, Stephen.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23
    strXlFile = "run.bat"
    strPath = "C:\ProgramData\Parsimony\A\D\FMP1"
    Shell strPath & strXlFile

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,798
    Sorry but I don't see the sense in breaking up the exact same path into variables just to piece them back together. Seems that the ending slash is missing in the path variable too.

    Try a Pause command at the beginning and end of your bat file. If there is a problem in your bat file one or both of the the pauses should display an error. Without the pauses, the file can terminate before Windows has a chance to display the problem message. That presumes you're not trying to use UNC paths but are showing C: in your post.
    Last edited by Micron; 09-10-2018 at 06:06 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23
    It is because you could run the following code:
    Code:
      strXlFile = "******.bat"
    strPath = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name)))
    Shell strPath & strXlFile
    this would run the BAT from the location of the database.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with calling a function
    By nello87to in forum Modules
    Replies: 7
    Last Post: 08-15-2016, 08:35 AM
  2. Calling DAO Close
    By BRZ-Ryan in forum Programming
    Replies: 2
    Last Post: 01-24-2014, 01:57 PM
  3. Calling and exe from code
    By drunkenneo in forum Access
    Replies: 1
    Last Post: 09-03-2013, 05:45 AM
  4. Calling previous value to add with new value
    By 2skannan in forum Programming
    Replies: 3
    Last Post: 01-23-2013, 11:33 PM
  5. calling function
    By ManvinderKaur in forum Programming
    Replies: 3
    Last Post: 07-22-2010, 10:53 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
  •  
Other Forums: Microsoft Office Forums