Checking if another application is running from C/SIDE

admoretutsieadmoretutsie Member Posts: 79
How can l go about checking if another application is running from within Navision??
$cside -MBS
>install Navision::4.0 SP1
>q
$
oOo

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What specific application do you want to test?
  • admoretutsieadmoretutsie Member Posts: 79
    The business notification client, ie MBS directory\businessnotificationmanager\notificationmanager.exe

    Thanks
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • garakgarak Member Posts: 3,263
    Here an example with the calc.exe

    Name	DataType	Subtype	Length
    WSHShell	Automation	'Windows Script Host Object Model'.WshShell	
    AppName	Text		30
    AppExe	Text		30
    WinStyle	Variant		
    
    if isclear(WSHShell) then
      create(WSHShell);
    
    AppName := 'Rechner';
    AppExe := 'calc.exe';
    WinStyle := 1;
    
    if not WSHShell.AppActivate(AppName) then
      WSHShell.Run(AppExe,WinStyle) //Startet den calc.exe
    else
      WSHShell.Popup('Läuft bereits'); //Bringt den Rechner in den Vordergrund
    
    clear(WSHShell);
    

    regards
    Do you make it right, it works too!
  • admoretutsieadmoretutsie Member Posts: 79
    Thnaks for the enlightment on the WSHShell automation server, it really is handy a shell. Where can l get all the methods for this automation server
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • garakgarak Member Posts: 3,263
    Use the C/AL Symbol Menu or take a look into variables and by the automation press F6. Here you can see, what WSH can do.

    regards
    Do you make it right, it works too!
  • admoretutsieadmoretutsie Member Posts: 79
    I have been looking at the methods provided by WSHShell, and none of them allows me to check if an application (e.g is calc.exe ) is currenlty running.

    A look at the following will illustrate what l am trying to say.

    http://msdn.microsoft.com/archive/defau ... ShellM.asp

    Unfortunately, that leaves my question open, but not as wide as it was at first.

    Regards
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • Timo_LässerTimo_Lässer Member Posts: 481
    [...] none of them allows me to check if an application (e.g is calc.exe ) is currenlty running.
    [...]
    If you can't acitvate the application with WSHShell.AppActivate(AppName) then it could be that the application is not started (or you have searched for the wrong AppName).
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • garakgarak Member Posts: 3,263
    By my (german) Windows, the Applicationname for calc.exe is 'Rechner'. You must change this to, i think, 'calculator' (?).

    Regards
    Do you make it right, it works too!
  • admoretutsieadmoretutsie Member Posts: 79
    Now, l had the AppName wrong, after changing the above example to "Calculator", it works just the way l wanted it to...

    Thanks guys!!!!!
    =D>
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • garakgarak Member Posts: 3,263
    Please.
    Do you make it right, it works too!
  • admoretutsieadmoretutsie Member Posts: 79
    It hits me hard, really hard. the problem:

    After implementing the "Calculator" example, when l manually run the codeunit, ( l created a codeunit (50000)) that has the above code), everything is ok. When l execute CODEUNIT.RUN(50000) in some trigger, a new calculator is being started. My codeunit 50000 is as follows:
    NB: Oyster is an OCX that has "SHELL" functionality and does not bring SHELL errors in some appliation paths.

    IF ISCLEAR(WSHShell) THEN
    CREATE(WSHShell);
    Navision := COMPANYNAME;
    NavisionExe := 'C:\Program Files\Microsoft Business Solutions-Navision 4.0\Client\finsql.exe';
    AppName := 'Calculator';
    AppExe := 'calc.exe';
    IF NOT WSHShell.AppActivate(AppName) THEN BEGIN
    Oyster.Oyster(AppExe);
    SLEEP(800); //Wait until the CALC is up and running by waitng for 8 seconds.
    END;
    //Bring Navision back to be the active screen
    IF NOT WSHShell.AppActivate(Navision) THEN
    Oyster.Oyster(NavisionExe);
    CLEAR(WSHShell);


    ](*,)
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • garakgarak Member Posts: 3,263
    Navision := COMPANYNAME;
    NavisionExe := 'C:\Program Files\Microsoft Business Solutions-Navision 4.0\Client\finsql.exe';

    Is it true, that the Navisionwindows name is only the companyname:?:

    My Navision shows the companyname and " - Microsoft business Solutions-Navision"
    Do you make it right, it works too!
  • admoretutsieadmoretutsie Member Posts: 79
    Navision := COMPANYNAME;
    NavisionExe := 'C:\Program Files\Microsoft Business Solutions-Navision 4.0\Client\finsql.exe';

    Is it true, that the Navisionwindows name is only the companyname:?:

    My Navision shows the companyname and " - Microsoft business Solutions-Navision"

    That is right, COMPANYNAME only is not the title tar text, but its the one that is running the Navision client. l think the existance of spaces in the text raises confusing in the appactivate() function. if you check out the appactivate API, it checks if the parameter is "contained" in the apps that are running. :-k
    $cside -MBS
    >install Navision::4.0 SP1
    >q
    $
    oOo
  • facadefacade Member Posts: 57
    Very handy thingy - but how can I kill the extra slave.exe 's :roll: :-k (or better use it within same slave), which is the result of running WSHShell.Run(AppExe,WinStyle) - the extra slave takes control over my printer and ... :-s ?
    Anybody :-k ?
Sign In or Register to comment.