Ok, this is very clear now. Nithin was correct to suggest Service mode.
To explain your problem clearly, a virtual machine has no monitor and only displays visual screen elements when a user is viewing through an RDP session. When its disconnected its basically not displaying a screen anywhere and therefore impossible to take a screenshot.
UiPath has Service Mode which should resolve this issue for you as it will spin up a session.
Try reinstalling UiPath Robot on the VM as Service Mode.
See here for another topic discussing it.