Global COTF Utility

Global COTF (https://virtamove.atlassian.net/wiki/spaces/VDOC/pages/311263613/Config-on-the-Fly?search_id=21080c33-27aa-479e-bd26-a263f355fed6) tool allows you to replace specific data in files or registry keys with any other custom data across the whole system.
For example, when migrating apps from old system to a new one, you may need to replace source machine identification information (hostname, IP address, etc.) with the destination machine ID information.

You are not limited to replacing hostnames. You can search for any text pattern and replace it with anything else. You can also specify a directory or registry path where to start searching for files containing the text pattern and whether to continue searching in sub-folders or not.

Usage

c:\globalcotf>globalcotf.exe /? VirtaMove Global COTF Utility Run COTF on a directory or registry key. Usage, 2 options - Default and Custom: GLOBALCOTF [/E] [/X] /D <path_search_in> <search_for> <replace_with> GLOBALCOTF [/E] [/X] /C <COTF-file.xml> [arguments] <path_search_in> The absolute directory or registry key path where to start looking for files with a keyword. Subdirectories are included. <search_for> The keyword to look for in files and registry keys. <replace_with> What to replace the keyword with. <COTF-file> The absolute/relative path for the custom COTF config file. arguments Optional arguments for the Config-on-the-fly settings file. Will replace $cotf0, $cotf1... placeholders in the file. /E Optional: Enables encryption detection mode. /X Optional: Enables detection of files with connection strings related to Databases and files containing JVM arguments. Note: Don't forget to use quotes for arguments containing a space!

There are two ways of using this tool: Default (/D) and Custom (/C).

globalcotf.exe /D "C:\Program Files" old_host_name new_host_name globalcotf.exe /C COTFconfigs\customCOTF.xml old_host_name

Default is an easy and fast way to replace some data with no extra configuration.

With Custom you can specify a config file that allows a high degree of customization over how exactly you want perform the COTF operation.

Here is an example of a COTF config file:

<?xml version="1.0" encoding="utf-8"?> <VirtaMove feature="config-on-the-fly" version="3.0"> <TARGET folder="C:\" include_subfolders="yes" entries="*.txt"> <EXCLUDE> <PATH>*\Windows*</PATH> <PATH>*.sys</PATH> </EXCLUDE> <ACTION type="replace"> <SEARCH>192.168.47.74</SEARCH> <REPLACE>192.154.56.1</REPLACE> </ACTION> <ACTION type="replace"> <SEARCH>Server2008R2-04</SEARCH> <REPLACE>%COMPUTERNAME%</REPLACE> </ACTION> </TARGET> <TARGET folder="HKEY_LOCAL_MACHINE\SOFTWARE" include_subfolders="yes" entries="*"> <EXCLUDE> <PATH>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft*</PATH> <PATH>HKEY_LOCAL_MACHINE\SOFTWARE\Classes*</PATH> <PATH>HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft*</PATH> <PATH>HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes*</PATH> </EXCLUDE> <ACTION type="replace"> <SEARCH>old_data</SEARCH> <REPLACE>new_data</REPLACE> </ACTION> </TARGET> </VirtaMove>

Nodes

The COTF file defines one or more TARGET nodes:

  • TARGET node - specifies the path(s) to be configured

  • EXCLUDE node - defines paths or files that you want to exclude from the TARGET node actions

  • ACTION node - specifies the action to be taken on the files found under TARGET path(s)

The TARGET node uses three attributes to define the paths and files that are to be configured:

  • folder - path where to start searching for files/registry keys

  • include_subfolders - optional, default value is "no". If set to "yes", then search will continue in all subdirectories or subkeys of specified folder

  • entries - specifies what files or registry key value entries to scan for a text pattern. "*" means any file, "*.txt" means only filenames that end with ".txt"

The entries attribute supports wildcard names, for example: "sql???.cfg", "HostInfo*", etc.

 

Each TARGET node can have multiple ACTION nodes. There are two types of ACTION nodes:

For replace, the action searches and replaces tokens (as defined in the SEARCH and REPLACE nodes). case_sensitive is an optional attribute with a default value "no".

COTF search and replace follows the "POSIX-Extended Regular Expressions" rules.

The execute type executes the executable defined in PATH with the arguments defined in ARGUMENTS for each entry matched in this TARGET node. %%TARGET%% placeholder can be used in ARGUMENTS. It will be replaced with a matched entry/file.