Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run external API in "silent mode"


Run external API in "silent mode"

Hello everybody,


I have a vb6 program that I must run in batch mode. What should I do to prevent MEGA windows to appear (for example when trying to connect to MEGA and when a MEGA session is already launched) and have error message instead (i.e. run it in batch mode).


Thank you for your help !



Tags (3)
6 Replies

Re: Run external API in "silent mode"



if your code is external to MEGA you have two options:

  1. your code run MEGA
  2. your code attach itself to an existing MEGA

In the first case you have to specify an user and a password to avoid the Login window (you cannot use CurrentEnvironment for instance), once connected plese use


to avoid ANY further popup or window


In second case you have to set a token (a value) inside the running instance MEGA by calling the


then in your external script you can get the currentEnvironement without the warning connection message.

You can then set MegaToolKit.SetInteractiveMode("Batch") to avoid other windows, also the MsgBox.


The MegaToolkit has to be got, how to get it depends on how you get the MegaRoot.


Claudio Pucci

Re: Run external API in "silent mode"

Thanks !!!Man Happy


Re: Run external API in "silent mode"

Hello Claudio,


It does not work for me because my problem is to manage connection problems (and you seem to say that it works only once connected).

Here is my code :

    Dim oMegaApp As New MegaApplication
    'The line I've added
    oMegaApp.Toolkit.SetInteractiveMode ("Batch")

    Set oEnvironnement = oMegaApp.Environments.item(myenv)
    oEnvironnement.CurrentAdministrator = user
    oEnvironnement.CurrentPassword = password
    Set oDatabases = oEnvironnement.Databases
    Set oDatabase = oDatabases.item(base)
    Set Connect2MEGA = oDatabase.Open


and despite the modification I made according to your advice, here is what happen (and what I want to avoid) when running my code while a MEGA Session is already running :




Is there a way to avoid this window and manage this error as I want in VB ?


Thanks !




Re: Run external API in "silent mode"

Hello Lionel,


the error you're having is because you're trying to run an external script on the same machine with the same user on the same repository, while MEGA is already running.


This is simply not possible, and cannot be avoided the msgbox because is not generated by the running MEGA but by the connction phase of you external code.


Claudio Pucci

Re: Run external API in "silent mode"

Hello Lionel


There is an attribute IsSessionOpen for an object MegaCurrentEnv

It can help you detect if the the MEGA application is active for a given environment


Re: Run external API in "silent mode"



as it is my code that runs MEGA, I do not have CurrentEnvironment (and therfore no access to the "IsSessionOpen".)

I tried with "IsAccessible" but it does not work.

As Claudio said, I think there is no solution (I could analyse Window's processes, but since MEGA is ran on a CITRIX server, it's a little bit complicated :-( )


Thanks to both of you for your help !