Quoting is tricky.
To list studies that would be:
dgate64 "--lua:q=DicomObject:new();q.PatientID=[[106019]];q.StudyInstanceUID=[[]];a=dicomquery([[CONQUESTSRV1]], [[STUDY]], q); local s=tempfile([[.txt]]) local f=io.open(s, [[wb]]) f:write(a:Serialize(true, true)) returnfile=s f:close();"
prints
[{"TransferSyntaxUID":"1.2.840.10008.1.2","QueryRetrieveLevel":"STUDY","PatientI
D":"106019","StudyInstanceUID":"1.3.46.670589.11.0.0.11.4.2.0.734.5.5972.2018110
911462251288"}]