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() var TempBlob: Codeunit "Temp Blob"; FileMgt: Codeunit "File Management"; Outstr: OutStream; TxtBuild: TextBuilder; Protocol: Text; CR: text; 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\""'; begin TxtBuild.Append("Program Filename"); TxtBuild.Replace('\', '\\'); CR := 13; CR := 10; Protocol := StrSubstNo(WinProtocolRegKeyTok, '%1', CR, TxtBuild.ToText()); TempBlob.CreateOutStream(Outstr); Outstr.WriteText(Protocol); FileMgt.BLOBExportWithEncoding(TempBlob, ProtocolLbl, true, TextEncoding::Windows); end;
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!!!!