Exclusive production of charmonium-like XYZ states in hadron-hadron ultraperipheral collisions(UPCs) and electron-proton scattering is studied employing effective Lagrangian method. Total cross sections and rapidity distributions of charmonium-like XYZ states are obtained in hadron-hadron UPCs and electron-proton scattering process. These predictions can be applied to estimate the observed event number of exclusive charmonium-like XYZ states in hadron-hadron UPCs and electron-proton scattering. The results indicate that it is significant to search $X(3872)$ and $Z^+_c(3900)$ in pA UPCs and Electron-Ion Collider in China will be an advantage platform to observe XYZ states in the future.