Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress MS-Office applications sending telemetry data programmatically

We are using MS-Office applications with an imported ActiveX typelibrary in our own applications (e.g. to convert MS-Office documents to PDF on the fly).

Our application intentionally waits until the MS-Office application background thread ends.
Since MS-Office version 2019 we noticed that the background thread blocks for a long time (18-25 seconds). The reason apparently is that telemetry data is sent as soon the MS-Office application is closed / quits.
This was proven by monitoring using the ProgMon tool.

We also found that there's a workaround, to disable sending telemetry data by manipulating the following registry key:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\Common\ClientTelemetry: REG_DWORD-Value (32bit): Disable Temetry: 1

If this is done the blocking time will go down to 3-5 seconds.

Here's a code snippet of what our application does (pretty much the core function we used to isolate and test the problem):

procedure TForm59.ConvertEarlyBinding(const _documentFilePath : string; 
                                      bOnlyOpenClose: Boolean = False);
var
    WordApp : ActiveX.TypeLibs.Word.Application;
    WordDoc : ActiveX.TypeLibs.Word.Document;

    oleTrue : OleVariant;
    oleFalse : OleVariant;
    emptyVariant : OleVariant;
begin
    oleTrue := True;
    oleFalse := False;
    emptyVariant := EmptyParam;

    WordApp := ActiveX.TypeLibs.Word.coApplication.Create;    
    WordApp.Visible := True;

    WordDoc := WordApp.Documents.Open(_documentFilePath, EmptyParam, oleTrue, 
                                      EmptyParam, EmptyParam, EmptyParam,
                                      EmptyParam, EmptyParam, EmptyParam, 
                                      EmptyParam, EmptyParam, EmptyParam, 
                                      EmptyParam, EmptyParam, EmptyParam, 
                                      EmptyParam);

    if not bOnlyOpenClose then begin
        WordDoc.ExportAsFixedFormat(ChangeFileExt(_documentFilePath, '.pdf'), 
                                    wdExportFormatPDF, false, 
                                    wdExportOptimizeForOnScreen, wdExportAllDocument, 
                                    -1, -1, wdExportDocumentWithMarkup, 
                                    false, false,
                                    wdExportCreateWordBookmarks, false,
                                    false, false, EmptyParam);
    end;

    WordApp.ActiveDocument.Close(oleFalse, emptyVariant, emptyVariant);
    WordDoc := nil;

    WordApp.Quit(false, EmptyParam, EmptyParam);

    WordApp := nil;
end;

Now the question is: Is there any property we can use from the MS-Office application interface, to prevent it from sending the telemetry data?

We well know, that we could also manipulate the registry keys programmatically from our application, but it would be preferable to suppress this only for the currently started MS-Office application instance.

like image 287
user11867718 Avatar asked Nov 07 '22 15:11

user11867718


1 Answers

Microsoft Office applications don't provide any property or method for that. To stop collecting data on the local computer, update the registry or set Group Policy settings as follows. By default, telemetry data collection is disabled in Office. Please check if your environment is enabled the telemetry agent before. Check the registry settings under:

HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\OSM
HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\OSM
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\OSM
HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\15.0\OSM

where 15.0 stands for Office 2013

If you are using Office 2016 upgraded from Office 2013 before, please also disable the Office 2013 telemetry agent. Please check the registry settings mentioned in the article below:

Deploy Office Telemetry Dashboard

Disable all Telemetry settings for Office users:

Manage the privacy of data monitored by Office Telemetry Dashboard

Disabling logging does not delete the data that has already been collected from a computer. To delete this data on the local client computer, delete the files evt.tbl, sln.tbl, user.tbl that are located under

%LocalAppData%\Microsoft\Office16.0\Telemetry\Microsoft\Office\16.0\Telemetry\.
like image 172
Eugene Astafiev Avatar answered Nov 15 '22 06:11

Eugene Astafiev