Starting a chrome with option specific user profile and to run headless. How to cater for headless execution?

Hello, i have a script to execute a testcase with specific chrome profile. However, how can i customize my script so that i can launch that testcase in headless mode? below is my script:

>      // Copy the path to chromedriver.exe
>     String pathToChromeDriver = 'C:\\Users\\XXXXX\\Documents\\POC_Katalon Studio\\Katalon_Studio_Windows_64-7.2.6\\configuration\\resources\\drivers\\chromedriver_win32\\chromedriver.exe'
> 
>         System.setProperty('webdriver.chrome.driver', pathToChromeDriver)
> 
>         // It is important that this chromeProfilePath ends with User Data and not with the profile folder (Profile 2)
>         String chromeProfilePath = 'C:\\Users\\XXXXXXX\\AppData\\Local\\Google\\Chrome\\User Data\\'
> 
>         ChromeOptions chromeProfile = new ChromeOptions()
> 
>         chromeProfile.addArguments('user-data-dir=' + chromeProfilePath)
> 
>         // Here you specify the actual profile folder (Profile 2)
>         chromeProfile.addArguments('profile-directory=Profile 1')
> 
>         WebDriver driver = new ChromeDriver(chromeProfile)
> 
>         driver.get(GlobalVariable.var_launchAppTest)
> 
>         DriverFactory.changeWebDriver(driver)
> 
>         //Ensure all chrome browsers are closed.

How can i modify this script to cater for headless execution?

This page may be relevant. It shows a way to add chrome profiles to Katalon, not exactly in the way you’re asking but it still may be helpful.

This document also has some tips on adding profiles to Web Services.

Hello, the solution is as shown below by just configuring desired capablities > Custom:

Thank you,