Batch Command Script
Mark Juras
Overview
- Pre/Post TranslationÂ
- Pre/Post DeploymentÂ
- Pre/Post Build
- Functional Test Task
Â
Execution of the Batch Command Script
If a batch command script is associated with an upgrade task, it will be executed along with the major batch operations. Â For example, during the deploy operation, gmStudio executes the following command line:
cmd.exe /C pushd "C:\gmSpec\Lang\OverloadArg\proj\log" && "migName-taskTag-lang.userCmdBatch.cmd" PRE-DEPLOY >"migName-taskTag-lang.bnd.log" 2>&1 && "C:\Program Files (x86)\GreatMigrations\gmStudio\\support\tools\deploy.exe" "migName-taskTag-lang.bnd" replace verbose >> "C:\gmSpec\Lang\OverloadArg\proj\log\migName-taskTag-lang.bnd.log" 2>&1 && "migName-taskTag-lang.userCmdBatch.cmd" POST-DEPLOY >>"migName-taskTag-lang.bnd.log" 2>&1 && popd  The command line executes five operations: 1) Make the workspace log folder the working folder 2) Run the batch command script passing PRE-DEPLOY 3) Run the deployment tool 4) Run the batch command script passing POST-DEPLOY 5) Reset the working folder The standard and error output of the batch script is joined with the output generated by the associated batch operation.
Structure of the Batch Command Script
The batch command script is a template file:  it supports an extensive set of parameter variables (i.e. %parameter%) that will be replaced by actual values associated with the upgrade project/task to create an actual batch command script. The replacements produce the Actual Batch Command Script in the workspace\log folder.   That Actual Batch Command Script  is executed before and after the associated batch operation being performed by gmStudio.  A listing of the actual batch script in the log folder may be viewed at the bottom of the Deploy Log display on the Information panel. Â
Batch Command Output
Activating a Batch Command Script
The UsrCmds field on each task record is where you specify the name of your batch script template. You will not typically specify the full path to your batch file, rather you will specify just the filename then place the script in the workspace\usr folder.  Â
The steps to associate a batch command script with an upgrade task are as follows:
- Click the task you want to add user batch handling for
- Client Edit Task Attributes in the Task Context menuÂ
This will display the task information editor - Enter the name UserCmd.cmd in the UserCmd fieldÂ
- Click Save
The tool will copy a default UserCmd.cmd from to your workspace\usr folder if one is not already there.Â
Editing a Batch Command Script
Once you have associated a batch command script with a task, clicking [Edit Task Script(s)] on the Task context menu will open the file in the editor along with the main translation task script.
Sample Batch Command Script
A listing of a sample batch command script template is shown below.  Notice there are examples of the script parameters and labeled sections that correspond to the different execution points. Â
This particular script has code in the TEST section which executes the .NET binary and compares its output with the output generated by running the VB6 code.Â
::---------------------------------------------------------------- :: This command script is executed before and after major steps :: in processing each migration job. You may insert your pre- :: or post processing steps as appropriate. :: This sample includes steps for setting up a web site build. :: :: The following gmStudio variables are available to use in the script :: :: AppExeFolder gmStudio Install Folder = %AppExeFolder% :: BldFileStem Path of Source Build File without Extension = %BldFileStem% :: BldPath Path of Source Build File = %BldPath% :: BndPath Path to generated code bundle file = %BndPath% :: DeployFolder Root folder for deploying .NET projects = %DeployFolder% :: DevEnv Visual Studio Version = %DevEnv% :: Dialect Target .NET Language = %Dialect% :: GenExternFolder Folder for generating interop files = %GenExternFolder% :: IdfFromCodeFolder Folder for IDFs generated from code = %IdfFromCodeFolder% :: IdfFromIdlFolder Folder for IDFs generated from COM binaries = %IdfFromIdlFolder% :: IntName Internal Name of Upgrade Task = %IntName% :: JobId Full ID of Task = %JobId% :: MigName Migration Project Name = %MigName% :: MigType Migration Project Type = %MigType% :: NetExtn Target .NET Language File Extension = %NetExtn% :: NetLang Target .NET Language = %NetLang% :: NetProjFolder Folder for deploying this task .NET project = %NetProjFolder% :: NetProjName .NET project name without Extension = %NetProjName% :: ProjFolder Folder for project workspace = %ProjFolder% :: ResxFolder Folder for generated RESX files = %ResxFolder% :: RuntimeFolder Folder for runtime support assemblies = %RuntimeFolder% :: SetEnvCmdPath Path to SetEnv.Cmd Script = %SetEnvCmdPath% :: SettingsFolder Folder for default Settings files = %SettingsFolder% :: ShellToolExe Path to Deployment Tool = %ShellToolExe% :: SrcFileStem Source File Name without Extension = %SrcFileStem% :: SrcFolder Folder for source code for this task = %SrcFolder% :: SrcName Short ID of upgrade Task = %SrcName% :: SrcOrdr Source Order for this task = %SrcOrdr% :: SrcPath Path to Source project/page = %SrcPath% :: TaskTag Task Tag = %TaskTag% :: UserFolder Folder for project user files = %UserFolder% :: UsrCmnt Task Comment = %UsrCmnt% :: UsrDesc Task Description = %UsrDesc% :: VirtualRoot Root folder for source code tree = %VirtualRoot% :: WorkFolder Working Folder = %WorkFolder% ::---------------------------------------------------------------- @ECHO OFF IF .%1==.PRE-TRAN goto PRE-TRAN IF .%1==.POST-TRAN goto POST-TRAN IF .%1==.PRE-DEPLOY goto PRE-DEPLOY IF .%1==.POST-DEPLOY goto POST-DEPLOY IF .%1==.PRE-MAKE goto PRE-MAKE IF .%1==.POST-MAKE goto POST-MAKE IF .%1==.TEST goto TEST echo UNKNOWN USER COMMAND: %1% goto END ::---------------------------------------------------------------- :PRE-TRAN ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter pre-translation processing here goto END ::---------------------------------------------------------------- :POST-TRAN ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter post-translation processing here goto END ::---------------------------------------------------------------- :PRE-DEPLOY ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter pre-deployment processing here (e.g. file replacement) ::echo setup directory folders for site ::robocopy "%VirtualRoot%" "%ProjFolder%\deploy" * /s /xf * /e ::echo deleting *.as* files from deployment %ProjFolder%\deploy ::if exist "%ProjFolder%\deploy\*.as*" del /s "%ProjFolder%\deploy\*.as*" ::if exist "%ProjFolder%\deploy\*.cs*" del /s "%ProjFolder%\deploy\*.cs*" goto END ::---------------------------------------------------------------- :POST-DEPLOY ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter post-deployment processing here (e.g. file replacement) ::robocopy "%VirtualRoot%" "%NetProjFolder%" *.jpg *.gif *.png *.vbs *.js *.css *.xls *.txt /np /s /NJH goto END ::---------------------------------------------------------------- :PRE-MAKE ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter pre-build processing here goto END ::---------------------------------------------------------------- :POST-MAKE ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter post-build processing here goto END ::---------------------------------------------------------------- :TEST ::---------------------------------------------------------------- echo USER COMMAND: %1 [%JobId%] :: Enter functional testing here pushd "%NetProjFolder%\bin" "%SrcName%.exe" popd echo file-report layout:side-by-side ^& > diff.bc echo options:display-mismatches,line-numbers ^& >> diff.bc echo output-to:%%3 %%1 %%2 >> diff.bc ::"c:\Program Files (x86)\Beyond Compare 3\BComp.exe" @"diff.bc" "%SrcFolder%\%SrcName%.log" "%NetProjFolder%\bin\%SrcName%.log" %SrcName%_test.log :: type %srcName%_test.log fc "%SrcFolder%\%SrcName%.log" "%NetProjFolder%\bin\%SrcName%.log" goto END :END