The following may work for you, i adapted some code i had testing AR invoices. There may be a better way but this worked for me during a brief test. I tested this with and without initializing the session UI object. As long as you don't ""process"" the invoice UI object, you should not have a ""UI"" appear.
'-----------------------------------------------------------------------
Set oShell = CreateObject(""WScript.Shell"")
sPath = """" : sPath = oShell.RegRead(""HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\SOTAMAS90\Directory"")
Set oPVXSession = CreateObject (""ProvideX.Script"")
oPVXSession.Init(sPath & ""\Home"") ' Make sure to set this path to point to the mas90 folder on the server
Set oSS = oPVXSession.NewObject(""SY_Session"")
nRetval = oSS.nInitiateUI()
Set oUI = oSS.oUI
'on error resume next
Set oScript = oSS.ScriptObject
nRetval = oSS.nSetUser(""user"", ""password"") ' Make sure to specify credentials
sCompanyCode = ""ABC""
sModuleCode = ""A/R""
sModuleDate = ""20200527""
nRetval = oSS.nSetCompany(sCompanyCode)
nRetval = oSS.nSetDate(sModuleCode, sModuleDate)
nRetval = oSS.nSetModule(sModuleCode)
oSS.nSetProgram(oSS.nLookupTask(""AR_Invoice_ui""))
Set oAR_Invoice_ui = oPVXSession.NewObject(""AR_Invoice_ui"", oSS)
Set oAR_Invoice_bus = oAR_Invoice_ui.ocoHeader
Set oAR_BatchHandle_ui = oAR_Invoice_ui.oBatchUIObj
Set oAR_BatchHandle_bus = oAR_BatchHandle_ui.ocoBusiness
sNextBatchNo = """"
nRetval = oAR_BatchHandle_bus.nOpenNextBatch(sNextBatchNo)
sRetval = oUI.sMessageBox("""", ""Next Batch Number: "" & sNextBatchNo & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg & vbCrLf & nRetval)
sBatchKey = oAR_BatchHandle_bus.sGetKeyPadded()
sRetval = oUI.sMessageBox("""", ""Current Key: "" & sKey & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg)
nRetval = oAR_BatchHandle_bus.nSetKey(sBatchKey) ' Not sure why but if this is a brand new batch and you don't call the ""SetKey"" method, the ""write"" method fails with the error ""the record is not in an editable state"".
sRetval = oUI.sMessageBox("""", ""Set Key: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg)
nRetval = oAR_BatchHandle_bus.nSetValue(""Comment$"", ""Test"")
sRetval = oUI.sMessageBox("""", ""Set Batch Comment: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg)
nRetval = oAR_BatchHandle_bus.nWrite()
sRetval = oUI.sMessageBox("""", ""Write Batch Comment: "" & nRetval & vbCrLf & oAR_BatchHandle_bus.sLastErrorMsg)
nRetval = oAR_Invoice_bus.nSelectBatch(sNextBatchNo)
sRetval = oUI.sMessageBox("""", ""Select Batch: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg & vbCrLf & sBatch)
sNextInvoiceNo = """"
nRetval = oAR_Invoice_bus.nGetNextInvoiceNo(sNextInvoiceNo)
sRetval = oUI.sMessageBox("""", ""Get Next Invoice No: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg & vbCrLf & sNextInvoiceNo)
nRetval = oAR_Invoice_bus.nSetKeyValue(""InvoiceNo$"", sNextInvoiceNo)
nRetval = oAR_Invoice_bus.nSetKeyValue(""InvoiceType$"", ""IN"")
nRetval = oAR_Invoice_bus.nSetKey()
sRetval = oUI.sMessageBox("""", ""Set Header Key: "" & nRetval & vbCrLf & oAR_Invoice_bus.sLastErrorMsg)
'-----------------------------------------------------------------------