Search code examples
sharepointinno-setupoffice365pascalscript

How can I use a SharePoint Site (365) as the source for Inno Setup files?


I would like to know in what way I can use a SharePoint site to download files during installation.

To do this I downloaded Inno Download Plugin and I tried to do some with the next code:

#include <idp.iss>

[Files]
Source: "{tmp}\FiletoDownload.txt"; DestDir: "{app}"; Flags: external; ExternalSize: 1048576

[Code]

function InitializeSetup(): Boolean;
var
  WinHttpReq: Variant;
begin
  Log('InitializeSetup');

  Result := True;

  try
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
    WinHttpReq.Open('GET', 'https://mysite.sharepoint.com', false);
    WinHttpReq.SetCredentials('myuser@mycompany.onmicrosoft.com', 'pass',1);    
    WinHttpReq.Send();
  except
  end;
end;

procedure InitializeWizard();
begin
  idpAddFileSize('https://mysite.sharepoint.com/Documents/Shared%20Documents/FiletoDownload.txt', ExpandConstant('{tmp}\FiletoDownload.txt.txt'), 1048576);
  idpDownloadAfter(wpReady);
end;

But when I compile appear this error:

enter image description here

Someone can help me explain where's my mistake?

Note: I read this post but according my understanding this applied to others SharePoint versions.

Thanks for advance!


Solution

  • It seems like you assume that using WinHttp.WinHttpRequest call SetCredentials you authenticate for the file download using "Inno Download Plugin".

    But these are two completely different unrelated HTTP sessions. It does not work this way.

    To authenticate with "Inno Download Plugin", use idpSetLogin function.

    See also Authenticated download with Inno Setup.


    Also the question you link, the How can I use a Sharepoint server as the Source for Inno Setup files?, is no way related to your problem. It's about downloading source files for the Inno Setup compiler, not for the installation.