Worked for me
I just needed a way to copy a database (everything) from a server that was saving the database data onto the D:\ drive.
But when I tried to restore on another box, the D:\ drive was assigned to the CD/DVD rom.
The T-SQL script worked like a charm. Thanks !