• Neil Roberts

Open an External Application on the Users Local Machine

In the last week I had gotten a request from a client that is using Business Central to create an action that will open an application that is installed on the users local machine.

Back in the day this would have been very easy to do, just use some .net within C/AL which will run on the role tailored client, all done.

In the Business Central world this is not possible, because the role tailored client does not exist anymore.

So how did I get around this issue.....?

Does anyone remember running the following command Dynamicsnav:////runpage?page=50000 , this is a protocol which is registered when NAV is installed.

So I did a very similar modification to create my own protocol to open an application on the users location machine.

First I had to write code to create the registry key which the user would have to download at least once onto their machine and install the new registry key.

procedure CreateAndDownloadProtocol()
    TempBlob: Codeunit "Temp Blob";
    FileMgt: Codeunit "File Management";
    Outstr: OutStream;
    TxtBuild: TextBuilder;
    Protocol: Text;
    CR: text[2];
    ProtocolLbl: Label 'Open Program Protocol.reg';
    WinProtocolRegKeyTok: Label 'Windows Registry Editor Version 5.00%2[HKEY_CLASSES_ROOT\OpenAnyProgram]%2@="URL:OpenAnyProgram Protocol"%2"URL Protocol"="OpenAnyProgram"%2[HKEY_CLASSES_ROOT\OpenAnyProgram\DefaultIcon]%2@="%3"%2[HKEY_CLASSES_ROOT\OpenAnyProgram\shell]%2[HKEY_CLASSES_ROOT\OpenAnyProgram\shell\open]%2[HKEY_CLASSES_ROOT\OpenAnyProgram\shell\open\command]%2@="%3 \"%1\""';
    TxtBuild.Append("Program Filename");
    CR[1] := 13;
    CR[2] := 10;

    Protocol := StrSubstNo(WinProtocolRegKeyTok, '%1', CR, TxtBuild.ToText());


    FileMgt.BLOBExportWithEncoding(TempBlob, ProtocolLbl, true, TextEncoding::Windows);

Great so now I should be able to open the application that has been setup against the "Program Filename" field, which in my case is "C:\Users\user\AppData\Local\Programs\GDT Where Used\GDTWhereUsed.exe"

Voila I get a notification asking me to open GDTWhereUsed.

Until next time, Happy Coding!!!!

33 views0 comments

Recent Posts

See All