VERIFIED SOLUTION i

Run a MapBasic application without displaying MapInfo Pro

Product Affected: MapInfo Pro™
How to run a MapBasic application invisibly without displaying MapInfo Professional.
 
MapBasic applications must always run within an instance of MapInfo Professional.  Sometimes users can interfere with a running Mapbasic application.  
There is a way, however, to run a Mapbasic application in the background to prevent user interaction.

 
 
The MapInfo Pro MapInfow.exe(32-bit) or MapInfoPro.exe (64-bit) can be run with the "-server" command-line parameter to prevent the splash screen and application from appearing. 
This allows MapInfo Pro to act as a hidden server to another application (using DDE) but also allows MapBasic applications to be run against it. 
If MapInfo Pro is first run with the "-server" parameter, then when the Mapbasic .mbx file is opened, the MapBasic application will launch in the most recently opened instance of MapInfo Professional which should be the "hidden" one.

 
Note: If the MapBasic application does not execute the "End MapInfo" statement at the end of the program, then MapInfo Pro will continue to run in the background indefinitely and will have to be terminated manually with Task Manager. 
Be aware that errors or dialogs requiring user input may prevent the MapBasic application from ever completing and terminating MapInfo Pro.  


 Attached is a VBScript file which will launch MapInfo Pro with the "-server" parameter, pause for 5 seconds, then launch a Mapbasic Application.  VBScript and Windows Scripting Host is required for this file to work, but this process can also be done manually or with another programming language.
 
 
VB sample code:
Dim oShell
 
Set oShell = CreateObject("Shell.Application")
 
'Execute MapInfo Professional in server mode
oShell.ShellExecute "MapInfow.exe", "-server", "C:\Program Files\MapInfo\Professional", "open", 0
 
'Sleep for 5 seconds
WScript.Sleep 5000
 
'Execute MapBasic app (will open in most recent instance of MapInfo Professional)
oShell.ShellExecute "Untitled.MBX", "", "C:\Program Files\MapInfo\Professional", "open", 0
 
Set oShell = Nothing
Set wShell = Nothing
 

 
 
MapBasic (MB) sample code to test for a hidden instance of MapInfo Pro:
Include "mapbasic.def"
 
Open Table "C:\Program Files\MapInfo\Professional\Data\Introductory_Data\NorthAmerica\USA\Usa_Maps\USA.tab"
 
Commit Table USA As "C:\usa.tab"
 
End MapInfo
UPDATED:  August 6, 2019