X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Shell Open Executable With Argument, Access 2013    
post Jun 21 2019, 04:27 PM

Posts: 61
Joined: 14-June 18

I'm using the ShellExecute API to launch an executable file from my access frontend.
Here is the API: http://access.mvps.org/access/api/api0018.htm

My problem is that I cant pass a argument to it. When I do it fails "File not found"

Any ideas on how I can achieve this?

here is my watered down code:

'   Get server file path
    Dim ServerPath As String
    Dim VersionNo As String
    Dim strProgramName As String
    Dim strArgument As String
    Dim strUpdatePath As String
    ServerPath = DLookup("[ServerPath]", "tbl_AppSystemFront")
    VersionNo = DLookup("[CurrentVersionNumber]", "tbl_AppSystemBack")
    strProgramName = ServerPath & "Current Installer\CIQ-Installer-" & VersionNo & ".exe"
    strArgument = " /PASSIVE"
    strUpdatePath = strProgramName & strArgument
    If (DLookup("VersionMatch", "qry_AppVersion") = "No") Then
        Call fHandleFile(strUpdatePath, WIN_NORMAL)

I was using a much simpler Shell which worked on windows 7 but not on windows 10 fails with run-time error 5 "Invalid Procedure Call or Argument."

Call Shell("""" & strProgramName & """ """ & strArgument & """", vbNormalFocus)

Go to the top of the page
Doug Steele
post Jun 21 2019, 06:43 PM

UtterAccess VIP
Posts: 22,177
Joined: 8-January 07
From: St. Catharines, ON (Canada)

Just guessing, but because of the space in Current Installer, try

  strUpdatePath = """" & strProgramName & """ " & strArgument

Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
post Jun 21 2019, 06:48 PM

Posts: 29
Joined: 19-June 19
From: Tasmania, Australia

can you try

debug.print """" & strProgramName & """ """ & strArgument & """"

just before you shell it and see what you get.
Go to the top of the page
post Jun 21 2019, 06:59 PM

Access Wiki and Forums Moderator
Posts: 75,712
Joined: 19-June 07
From: SunnySandyEggo

Hi. Shell should still work on Windows 10, but I’m not in front of a computer right now to test it.

Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
post Jun 21 2019, 07:22 PM

Posts: 2,458
Joined: 4-February 07
From: USA, Florida, Delray Beach

Dim retVal As Variant
Dim strArgument As String

strArgument = "C:\Test\Test File.txt"

retVal = Shell("Notepad.exe " & strArgument, vbNormalFocus)
Go to the top of the page
post Jun 24 2019, 12:40 AM

Posts: 61
Joined: 14-June 18

Okay so maybe the shell issue isn't a windows 7 vs 10 thing. Could it be a 32 vs 64 bit issue?
Go to the top of the page
post Jun 24 2019, 12:59 AM

Posts: 29
Joined: 19-June 19
From: Tasmania, Australia

Did you confirm the file path for the executable is the same on the machine that isn't cooperating.
also can you log in as an admin user on that machine and try as well to rule out a permissions thing.
This post has been edited by ITguaranteed: Jun 24 2019, 01:00 AM
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    17th July 2019 - 11:56 AM