7coil/DiscordForOffice

Differentiate between Microsoft Office 2016 and 2019 with VSTO

7coil opened this issue · 9 comments

7coil commented

Microsoft in their infinite wisdom decided to make the Office version of 2019 "16.0" - The exact same as 2016.

The function getVersion() at /Shared/Shared.cs needs to return the string "2013", "2016" or "2019", depending on what version of Microsoft Office they are using.

(bonus points for detecting Office 365)

Hey @7coil,

I'm trying to work on this issue for #hacktoberfest, however, I can't seem to get the project building.

To reproduce:

  1. Clone the repo
  2. Open in VS2019
  3. Attempt to build project
  • I've attempted to disable the ClickOnce signing but this doesn't work. Is there a temp certificate that needs to be included?

image

7coil commented

Yeah, try a temporary certificate

@DannyAllegrezza good luck, i had a go with this the other day, I'm interested to see how/if you solve it.
I've posted a question to one of the microsoft forums, MSDN docs indicate that a few of the versions will report the same version numbers, and I hadn't found a nice way to reliably differentiate the app versions via alternate means, so admitted defeat for the time being.

Yeah, try a temporary certificate

Can you provide some reference on how to generate one/getting project compiling? I'm glad to open a PR to update the docs but as of right now I don't know how to get it building.

Nevermind, I figured it out. Was right in front of me earlier but had never run into this problem. You may want to consider removing the .pfx files from the repository, or actually adding them to the project.

7coil commented

Sorry, I don't usually work with C# projects, so I haven't really made it easy to work with properly
Thanks

I couldn't see an obvious way to do this. However, Microsoft have a rather complex vbs script available which purports to reliably differentiate between office products, might be worth a look:
https://gallery.technet.microsoft.com/office/68b80aba-130d-4ad4-aa45-832b1ee49602

7coil commented

I've been poking around in the registry and found something that might help...

[HKEY_USERS\S-1-5-21-369044061-3658407648-47840922-1001\Software\Microsoft\Office\16.0\Common\Licensing\BootTimeSkuOverride]
"{C4ACE6DB-AA99-401F-8BE6-8784BD09F003}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"
"{3CFF5AB2-9B16-4A31-BC3F-FAD761D92780}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"
"{7C6D92EF-7B45-46E5-8670-819663220E4E}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"
"{7ECBF2AA-14AA-4F89-B9A5-C064274CFA83}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"
"{DC5CCACD-A7AC-4FD3-9F70-9454B5DE5161}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"
"{E0A76492-0FD5-4EC2-8570-AE1BAA61DC88}"="{149DBCE7-A48E-44DB-8364-A53386CD4580}"

It seems like the product SKU of office is being overwritten with another SKU, that being 149DBCE7-A48E-44DB-8364-A53386CD4580

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\Registration\{149DBCE7-A48E-44DB-8364-A53386CD4580}]
"ProductName"="Microsoft 365 Apps for enterprise"
"ProductNameBrand"="Microsoft 365 Apps for enterprise"
"SuiteName"="Part of Microsoft 365 Apps for enterprise"

The name is just there to be used by DiscordForOffice yum yum

7coil commented

image

Looks like it's (kinda) working, but I don't have standalone versions of 2016 and 2019 to help try this out.