Overview
This document describes how to use environment variable MFVersion to distribute new vault connection. Same method can be used to distribute another M-Files registry settings too.
Solution
M-Files has environment variable called MFilesVersion which can be used with GPO and scripts. When you are using this variable, you don't need to know which M-Files version installed on end user computer.
M-Files registry settings are version-specific: the version of M-Files appears as a key under the Software\Motive\M-Files key. For example, all registry settings for M-Files version 21.10.10725.5 would appear under the following key name: "Software\Motive\M-Files\21.10.10725.5 ". In order to make it easier for you to distribute registry settings via a GPO or script files, without necessarily knowing the version of M-Files that is installed on a particular target computer, M-Files setup sets a system environment variable named MFilesVersion when M-Files is installed. The value of the MFilesVersion system environment variable contains the M-Files version string such as "21.10.10725.5 ". The MFilesVersion variable is supported in M-Files 11.0.4207.0 and later.
If the computer has multiple versions of M-Files installed, the MFilesVersion variable refers to the newest version on the computer (regardless of the order in which the versions have been installed). For example, if you have installed versions 21.10.10725.5 and 21.09.8.0524.6 on the same computer, the value of the MFilesVersion system environment variable is 21.10.10725.5. In most production-use environments you would expect users to have only a single version of M-Files installed.
You can deploy registry settings on client computers to using registry files,.cmd, .bat or PowerShell scripts. The .cmd or .bat file can call the REG command to add registry values. PowerShell uses its own method to add registry values. The execution of a script file resolves any environment variables, meaning that you can use the %MFilesVersion% placeholder in the script files to refer to the install M-Files version.
You may distribute registry settings with registry (.reg) files as well, but since .reg files do not support the use of environment variables in key names, you would need to modify the .reg file for each M-Files version.
Here is example of .bat/.cmd- and PowerShell commands how to distribute new vault connection settings using MFilesVersion environment variable. These commands add new vault connection called "Sample Vault" for all users (HKEY_LOCAL_MACHINE\):
.BAT/.CMD:
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v NetworkAddress /t REG_SZ /d 192.168.1.102 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v ProtocolSequence /t REG_SZ /d ncacn_ip_tcp /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v Endpoint /t REG_SZ /d 2266 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v Secured /t REG_DWORD /d 0 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v ServerVaultName /t REG_SZ /d "Sample Vault" /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v AuthType /t REG_DWORD /d 00000003 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v AutoLogin /t REG_DWORD /d 00000000 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v ServerVaultGUID /t REG_SZ /d {9FAB3020-9788-4EFC-BA4D-2D00CFCAD426} /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v HTTPProxy /t REG_SZ /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v ID /t REG_DWORD /d 2 /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v InfoTip /t REG_SZ /f
REG ADD "HKLM\Software\Motive\M-Files\%MFilesVersion%\Client\MFClient\Vaults\Sample Vault" /v SPN /t REG_SZ /f
POWERSHELL:
New-Item -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults" –Name "Sample Vault"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "NetworkAddress" -Value "192.168.1.102" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "ProtocolSequence" -Value "ncacn_ip_tcp" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "Endpoint" -Value "2266" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "Secured" -Value "0" -PropertyType "DWord"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "ServerVaultName" -Value "Sample Vault" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "AuthType" -Value "00000003" -PropertyType "DWord"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "ServerVaultGUID" -Value "{9FAB3020-9788-4EFC-BA4D-2D00CFCAD426}" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "HTTPProxy" -Value "" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "ID" -Value "2" -PropertyType "DWord"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "InfoTip" -Value "" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "SPN" -Value "" -PropertyType "String"
New-ItemProperty -Path "HKLM:\Software\Motive\M-Files\$env:MFilesVersion\Client\MFClient\Vaults\Sample Vault" -Name "AutoLogin" -Value "00000000" -PropertyType "DWord"
NOTE. When adding new vault connection using registry entries, restart of M-Files Desktop service is required after registry entries have been applied.
Reference Documents
KB.cloudvault.m-files.com M-Files Setup: Advanced User's Guide
