In general, it can't be done. Some games are written to copy all necessary files to your hard drive so that the CD/DVD is not needed, but many games do not do that. There are also games that use copyright protection requiring the CD/DVD to remain in a drive.
You can get around some of this with software that emulates CD/DVD disks. Images are made and mounted rather than actual disks. There are also NO/CD patches available for some games.
However, you will need to do your own research on this as it is, I believe, a subject prohibited on this site.