KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: AP ShellExecute: -43 error - File Not Found Error is this because of spaces?
PRODUCT: 4D Pack | VERSION: 2004 | PLATFORM: Mac & Win
Published On: October 24, 2007

AP ShellExecute is a 4D Pack command that allows you to launch an application or open a document from with a 4D Database. It can be used for almost any file system purpose. You are allowed to have spaces in the path and file name. This is a common misconception! You do not need to 'escape' (by using a double \ on Windows or quotes "" on OS X) the path for it to be recognized properly.

An example would be to open a Microsoft Word document from within 4th Dimension.

On Mac OS X the following commands would work:

Using HFS path notation:
$err:=AP ShellExecute ("Production:Users:slack:test.doc")

Using POSIX path notation:
$err:=AP ShellExecute ("/Users/slack/test2.doc")

$err:=AP ShellExecute ("/Users/slack/test jason.doc")

$err:=AP ShellExecute ("/Users/slack/test documents/test jason.doc")

$err:=AP ShellExecute ("/Users/slack/test documents/test jason document.doc")

Each one of these examples illustrates a different example call using both spaces in the file name and directory names.

On Windows the following commands would work:

$err:=AP ShellExecute ("C:\Test.doc")

Windows also has an additional parameter to allow a specific document, website or really any valid path to the application you are requesting be opened.

This example would display the contents of the Music directory in Windows Explorer:
$err:=AP ShellExecute ("C:\WINDOWS\explorer.exe";0;"C:\Music")

If you do indeed receive a -43 (File Not Found) error, make sure to check the path to the file you are requesting.

As a possible alternatives, you can also look into the 'AP Sublaunch' command at:

https://www.4d.com/docs/CMU/CMU61989.HTM

Or the 'Launch External Process' command at:

https://www.4d.com/docs/CMU/CMU00811.HTM