Although Visual Studio Community Edition is supposed to be free, you are required after 30 days by the graphical interface to have an account on Microsoft’s online services to continue to use the product. The trial period reset of Visual Studio Community Edition can however be easily achieved by editing the registry.
As mentioned in this StackOverflow question, the expiration date for these 30 days are registered in a registry value protected by the CryptProtectData API. The algorithm is then
- Get the value in HKCR\Licenses\5C505A59-E312-4B89-9508-E162F8150517\08878 for VSCE 2017 or HKCR\Licenses\41717607-F34E-432C-A138-A3CFD7E25CDA\09278 for VCSE 2019
- Decrypt the value with
CryptUnprotectData
. - Get and change the values in bytes -16,-15 (YY), -14,-13 (MM), -12, -11 (DD)
- Encrypt the value with
CryptProtectData
. - Set the value back in the registry where you found it.
In Powershell, a module has been published which does this. However, the manifest was not properly edited, so you can find an updated version with the following changes:
- CompatiblePSEditions is valid for Powershell 5.1 or higher
- The RequiredAssemblies to load, in this case System.Security for the Cryptography functions, directive takes an array of strings, not a simple string
If you want a ready-to-use solution, i.e. a MSI Installer which installs the module without the need for an internet connection and a scheduled task to periodically reset the period, just go to thegithub repo for this project.
But is there any guide to follow for the powershell option? Because the guide is to poor
The Powshell module exposes only 2 cmdlets, with help description provided.
Are those values in hex or decimal?
Get and change the values in bytes -16,-15 (YY), -14,-13 (MM), -12, -11 (DD)
Each date component is stored as a 16-byte integer. See [System.BitConverter]::GetBytes([uint16]$_) in the ConvertTo-BinaryDate function of the code at https://github.com/1Dimitri/VSCELicense/blob/master/VSCELicense.psm1
Thanks for the script đŸ™‚
Here is the howTo that was asked for:
Make a directory for the 2 files (VSCELicense.psm1 and VSCELicense.psd1) and make the two files with copy pasting and notepad or your favorite editor
put all files in the same directory and start a powershell with admin priviledges.
In the following lines change vs2019 to the version you have installed.
Then type (or copy paste. You might have to copy paste and execut every line individually.):
#StartOfCommands
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
$currentDirectory = Get-Location
Import-Module $currentDirectory\VSCELicense
Get-VSCELicenseExpirationDate
Set-VSCELicenseExpirationDate -Version 2019
Get-VSCELicenseExpirationDate
Remove-Module VSCELicense
#EndOfCommands
—–
If you close the powershell window the priviledges will revert to what they were before.
Just open a new one and type:
Get-ExecutionPolicy -list
đŸ™‚ Done!
You can also find a MSI to install the module and have a scheduled task in https://github.com/1Dimitri/VSCELicense/releases/tag/1.0
This doesn’t work anymore.
Get-VSCELicenseExpirationDate crashes with an error on Date
ConvertFrom-BinaryDate : Cannot validate argument on parameter ‘Year’. The -1 argument is less than the minimum
allowed range of 1. Supply an argument that is greater than or equal to 1 and then try the command again.
At C:\Reset Visual Studio\VSCELicense.psm1:176 char:38
+ … ationDate = ConvertFrom-BinaryDate $LicenseBlob[-16..-11] -ErrorActio …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertFrom-BinaryDate], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,ConvertFrom-BinaryDate
Hzllo, I do not have this behavior on the machines I checked the package.
THe license for VS2019 is reset on Windows Server 2019 (PS 5.1) and Windows 10 2004.
Is it for VS2015, 2017 or VS2019? Could you check in the scheduled task since when this happens?
Hello, is this solution will work with the version VS 2017 Enterprise ?
I haven’t tested it with anything except the Community edition. You may want to look at a before/after VSinstall comparison of the edition you’re interested in under HKEY_CLASSES_ROOT\Licenses to see if they map to one of the already known values in the code at https://github.com/1Dimitri/VSCELicense/blob/master/VSCELicense.psm1
Dimitri, Could you make an executable file to run the whole process automatically?
I’ve put MSI Installers with the module and some scheduled task on https://github.com/1Dimitri/VSCELicense/releases/tag/1.0
Hi Dimitri, can you offer an explanation for beginners? I tried the MSI installer but the countdown did not reset. I guess I am missing something obvious?
Hello, the countdown is reset when the scheduled task is run during the night or at the next boot. So if your license had already expired when you installed it, you would have to run the task manually (as an elevated administrator otherwise it doesn’t appear).
Very good solution. You are a genieus.