Start Application

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  The MapForce API > Overview > Examples > JScript Examples >

Start Application

The JScript code listing below starts the application and shuts it down. If an instance of the application is already running, the running instance will be returned.

 

Note:For 32-bit MapForce, the registered name, or programmatic identifier (ProgId) of the COM object is MapForce.Application. For 64-bit MapForce, the name is MapForce_x64.Application.

 

// Initialize application's COM object. This will start a new instance of the application and
// return its main COM object. Depending on COM settings, a the main COM object of an already
// running application might be returned.
 
try {   objMapForce = WScript.GetObject("", "MapForce.Application");   }
catch(err) {}
 
if( typeof( objMapForce ) == "undefined" )
{
  try   {   objMapForce = WScript.GetObject("", "MapForce_x64.Application")   }
  catch(err)
  {
     WScript.Echo( "Can't access or create MapForce.Application" );
     WScript.Quit();
  }
}
 
// if newly started, the application will start without its UI visible. Set it to visible.
objMapForce.Visible = true;
 
WScript.Echo(objMapForce.Edition + " has successfully started. ");
 
objMapForce.Visible = false; // will shutdown application if it has no more COM connections
//objMapForce.Visible = true;   // will keep application running with UI visible

 

The code listed above is available as a sample file (see JScript Examples). To run the script, start it from a command prompt window or from Windows Explorer.

 


© 2019 Altova GmbH