Call external program from workflow

Hello,

I am trying to call a custom app from workflow in M-Files (from vbcript). Version of M-Files is 21.6.10322.8.

So, I created new console application (ConsoleApp1) in Visual Studio 2019

namespace ConsoleApp1
{
   class Program
   {
       static void Main(string[] args)
       {
              Console.WriteLine("TEST");

              // code below writeline  never gets executed from workflow

              var app = new MFilesAPI.MFilesClientApplication();
              var vaults = app.GetVaultConnections();

        }

}

}

My intention here is to have c# code which would connect to a particular vault in M-Files and upload documents. And I have such code in this app, and that works when I start that ConsoleApp1.exe directly from Visual Studio or Windows Explorer.

In M-Files, I created workflow with one state (s1) which has VBScript:

Option Explicit

Dim objWScript
Set objWScript = CreateObject("WScript.Shell")

Dim objExec
Set objExec = objWScript.Exec("c:\test\ConsoleApp1.exe")

And, when I start the workflow and set state to s1, message is displayed "TEST", but after that, there is an error:

CoScriptObjectFactory.cpp, 465, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
ScriptErrorHelper.cpp, 96, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MDispatchExImpl.h, 694, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MDispatchExImpl.h, 994, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataCardAction.cpp, 386, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataCardAction.cpp, 570, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataEditor.cpp, 2967, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataModel.cpp, 4244, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataModel.cpp, 4681, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
ElectronicSignatureUIHelper.cpp, 235, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MetadataModel.cpp, 12169, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 3204, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
DocumentCache.cpp, 11284, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
DocumentCache.cpp, 11393, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
DocumentCache.cpp, 19560, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCMethodCallWithRetry.h, 35, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperations.cpp, 12721, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperations.cpp, 7386, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
MCallInLoop.h, 712, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 4157, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 3718, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 9423, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 10014, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 27602, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 2908, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3120, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 3540, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 4379, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 269, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, Script execution failed. ((s1, StateAction: 4-12)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, No M-Files error description available. (0x80040007)
VaultScriptSessionTemplates.cpp, 510, No M-Files error description available. (0x80040007)
CoActiveScriptSite.cpp, 894, No M-Files error description available. (0x80040007)
CoActiveScriptSite.cpp, 736, No M-Files error description available. (0x80040007)
s1, StateAction, 11, No M-Files error description available. (0x80040007)
MErrorHelper.cpp, 2449, No M-Files error description available. (0x80040007)
(M-Files 21.6.10322.8)

And whatever code is there, it doesn't matter, M-Files will return error and nothing else.

I repeat, ConsoleApp1.exe works great when started directly from Windows Explorer, but not from M-Files workflow.

What am I doing wrong?