Navigation: Commands and Procedures > Predefined Macros >
Visual Build provides the following predefined system macros and tools. Windows also defines some of these macros as environment variables, which will take precedence over Visual Build's definition (if enabled on the General application options page), and you can override these values by defining your own project or global macros or environment variables. Some values vary depending on the current date/time, project, or step being processed:
COMPUTERNAME: The current computer name.
COMSPEC: Path and filename of the command shell executable (cmd.exe).
Note: To call the 64-bit version of cmd.exe from the 32-bit edition of Visual Build, create a COMSPEC global macro with a value of %WINDIR%\Sysnative\cmd.exe; to call the 32-bit version of cmd.exe from the 64-bit edition of Visual Build, create a COMSPEC global macro with a value of %WINDIR%\SysWOW64\cmd.exe.
DATE: Inserts the current date. The date will be formatted according to the Short Date style in the Control Panel Regional Settings for dates.
DATETIME: Inserts the current date and time. The value will be formatted according to the Short Date and Time styles in the Control Panel Regional Settings for dates.
Note: Script code can also be used to insert date values with specific formatting. For instance, to insert the date in the format YYYY-MM-DD, use the VBScript expression [Year(Now) & "-" & Month(Now) & "-" & Day(Now)] in any step field. See the scripting function reference on MSDN for more details. System scripts for formatting dates are also provided.
DOSCMD: Executes an operating system command (i.e., DIR, COPY, ECHO, etc.), batch file, or command script using cmd.exe. Use this in a Run Program action to execute batch files, command scripts, individual shell commands, or to execute a program under the command shell for redirection (> or >>) or piping (|) of that program's output.
Note: To call the 64-bit cmd.exe from the 32-bit edition of Visual Build, create a COMSPEC global macro with a value of %WINDIR%\Sysnative\cmd.exe. To call the 32-bit version of cmd.exe from the 64-bit edition of Visual Build, create a COMSPEC global macro with a value of %WINDIR%\SysWOW64\cmd.exe.
FAILSTEP_OUTPUT: Contains the output from the failed step.
Note: The FAILSTEP_OUTPUT macro includes any output logged by actions that was not output due to the step's Disable logging option being checked or the global logging level being lower than the message's log level.
LASTSTEP_OUTPUT: Contains any output from the last step that was processed. This can be useful for parsing the output for error information in the following step or the step's vbld_StepDone script event.
Note: The LASTSTEP_OUTPUT macro includes output logged by actions that was not output due to the step's Disable logging option being checked or the global logging level being lower than the message's log level.
LOGFILE: The filename of the log file (an empty string if logging is not enabled). This will be the setting configuration in Application Options; it can also be overridden by a global, project, or temporary LOGFILE macro.
PROCFILES_FULLPATH: The full path and filename of the current file for the Process Files action.
PROJDIR: The full path of the open Visual Build project file. Useful for accessing other files that will be located relative to the project, allowing projects to work correctly no matter which drive or root directory they are placed at on a particular machine.
PROJFILE: The full path and filename of the open project file.
PROJROOT: The root name of the project file without extension.
QUOTE_STR: Ensures that a string has double quotes around it.
READ_INI: A macro used to read a value from an INI file and use in a step field. The syntax for calling it is: %READ_INI(filename, section, valuename, [default])%. Filename must be the full drive+path+filename for the file. The Read INI action can also be used to read INI files.
READ_XML: A macro to read an element or attribute from an XML file and use in a build step. The syntax for calling it is: %READ_XML(filename, xpath[, default][, namespaces])%. xpath denotes an XPath expression to search for; the text of the first matching node is returned or a blank string if not found. namespaces specifies one or more namespaces aliases separated by spaces (i.e., xmlns:bk='book' xmlns:n='http://testuri'). The Read XML action can also be used to read XML files.
Note: This macro requires MSXML version 3.0 or later to be installed.
REG_READ: A macro to read a value from the registry and use in a build step. The syntax for calling it is: %REG_READ("hive\key\value", ["default"])%. If an empty value is provided for the default parameter and the value is not found, an error occurs. To read the default value of a key, use an ending backslash character (i.e., %REG_READ("HKEY_CURRENT_USER\Software\Test\Key\",)%). To read value names containing backslashes, use a double-backslash to delimit the key/value (i.e., %REG_READ("HKEY_CURRENT_USER\Software\Test\\Value\Name",)% would read a value named Value\Name). See the RegEdit.bld sample for more details.
TEMP: The temporary path.
TOOLSDIR: The location of built-in Visual Build and miscellaneous third-party tools (usually C:\Program Files\VisBuildPro10\Tools). Note: This directory is only created for a Full installation.
TRIM_QUOTES: Strips any double quotes surrounding a string value.
USERNAME: The logged on user's username.
VISBUILD: The full path to the current instance of Visual Build. Use to build another project from the current project (see the Chain.bld sample).
VISBUILDDIR: The path of the current instance of Visual Build.
VISBUILDVER: The version of the current instance of Visual Build.
WINDIR: The Windows directory.