xcomend.bat script date format problem after Windows XCOM server migration
book
Article ID: 414930
calendar_today
Updated On:
Products
XCOM Data TransportXCOM Data Transport - WindowsXCOM Data Transport - Linux PC
Issue/Introduction
Have migrated XCOM 11.6 SP00 to new Windows Server 2019 machine and XCOM version 12.0. The XENDCMD script xcomend.bat adds a timestamp to the end of the incoming file name. However on the new machine the timestamp format is YYYYDDMMHHMISS instead of required YYYYMMDDHHMISS i.e. the date part of the format is incorrect.
The xcomend.bat uses this line to set the DateTime variable which is used in the file name: set DateTime=%DATE:~-4%%DATE:~4,2%%DATE:~7,2%%str%%TIME:~3,2%%TIME:~6,2%
Resolution
Initially Support advised to change the Region settings (Formats) for the transfer user because it is that user that is executing the xcomend.bat and the Regions settings would be user specific. However that was still not successful. Later tests by Support using a Windows Server 2019 VM with "English (United States)" set for both Region and Windows display language indicated that the user's Region settings were not relevant. Using the same xcomend.bat script they could not recreate the problem and the file gets appended with the script %DateTime% value which has required date format YYYYMMDD.
Later support suggested alternative solution using a Powershell cmdlet 'Get-Date -Format "yyyyMMdd"' to get the date in required format and therefore not rely on Region settings. So in the script set the result of that command to another variable DATE1 and then use that for set the DateTime variable i.e. Instead of this line: ***** set DateTime=%DATE:~-4%%DATE:~4,2%%DATE:~7,2%%str%%TIME:~3,2%%TIME:~6,2% ***** Use these 2 lines, the first (new) one setting the DATE1 variable and the other updated line for DateTime becomes simpler because DATE1 is already in the correct format: ***** FOR /F "delims=" %%i IN ('Powershell.exe Get-Date -Format "yyyyMMdd"') DO SET "DATE1=%%i" set DateTime=%DATE1%%str%%TIME:~3,2%%TIME:~6,2% ***** That was successful for the user.