CDR.EXE - Open/Close CD Drive(s) Programmatically

In Windows Explorer, you can right-click on a CD-Drive and select the "Eject" option to open the CD Drive. Unfortunately, there is no "Close" equivelant to Close the drive. This project builds a command-line program that lets you open or close any or all of your CD-Drives.

To display the program's usage, run the program with no parameters:

C:\> CDR
CDR by Chris M. Sebrell
 CDR [open|close] [Drive-Letter|ALL]
 CDR open E:
 CDR close ALL

To OPEN or CLOSE the first logical CD Drive:
C:\> CDR open
C:\> CDR close

If you have more than one CD Drive, you can specify a drive letter:

C:\> CDR open g:
C:\> CDR close g:

If you have more than one CD Drive, you can specify ALL drives:

C:\> CDR open all
C:\> CDR close all

The main work routine in the program is CD_OpenClose(BOOL bOpen, TCHAR cDrive)

//Open or Close CD Drive
//cDrive is Drive Letter to Open, or 0x01 for 'Default' drive
//CD_OpenCloseDrive(TRUE, 'G');  //Open CD Door for Drive G: 
//CD_OpenCloseDrive(FALSE, 'G'); //Close CD Door for Drive G:
//CD_OpenCloseDrive(TRUE, 1);    //Open First Logical CD Door
void CD_OpenCloseDrive(BOOL bOpenDrive, TCHAR cDrive)
 DWORD flags;

 TCHAR szDriveName[4];
 strcpy(szDriveName, "X:");

 ::ZeroMemory(&op, sizeof(MCI_OPEN_PARMS));
 op.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;

 if(cDrive > 1)
  szDriveName[0] = cDrive;
  op.lpstrElementName = szDriveName;
  flags = MCI_OPEN_TYPE 
        | MCI_OPEN_TYPE_ID 
 else flags = MCI_OPEN_TYPE 
            | MCI_OPEN_TYPE_ID 
            | MCI_OPEN_SHAREABLE;

 if (!mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&op)) 
  st.dwItem = MCI_STATUS_READY;



Next, to facilitate operating on ALL CD Drive Doors, add this routine (which calls the CD_OpenCloseDrive() function above):

void CD_OpenCloseAllDrives(BOOL bOpenDrives)
 // Determine All CD Drives and Open (or Close) each one
 int nPos = 0;
 UINT nCount = 0;
 TCHAR szDrive[4];
 strcpy(szDrive, "?:\\");

 DWORD dwDriveList = ::GetLogicalDrives ();

 while (dwDriveList) {
  if (dwDriveList & 1) 
   szDrive[0] = 0x41 + nPos;
   if(::GetDriveType(szDrive) == DRIVE_CDROM)
   CD_OpenCloseDrive(bOpenDrives, szDrive[0]);
  dwDriveList >>= 1;

That's all! The download includes source code & the compiled CDR.EXE program. If anyone has additions, corrections, or a whole new approach to this, I'd love to hear about it. I'll update this project with any new useful information I receive.


Download project (Source & Executable)- 32 Kb


  • Thank you‼

    Posted by CaptainTech / theTechLord / TechLord777 on 03/20/2016 10:20am

    Great thanks for your great tool; and great thanks for sharing it's source code with us! This little piece of software has really useful features. I can use PsExec/PAExec to remote-control disc trays of other computers.

  • Testing CDR

    Posted by Felipe R Valera on 08/12/2015 10:10pm

    Well, i tested this program using Windows 7, CDR open when we specify the drive letter and CDR open all works perfectly, if i use CDR open plain it delay a lot, and sometimes don't open; CDR close , CDR close all are not working , Great program.

  • 2013 fascination and entertainment goods online on wonderful, Seize more you products onw

    Posted by Glonesciece on 06/24/2013 04:31pm

    Anyone who says that sparkle and glitter are a trend of the past, clearly hasn't met our friend, Jimmy.The Candy Clutchand Viola Crystal Sandals by Jimmy Choowill ensure that all eyes are on youwhen strutting downthe VIP carpet (even ifthe closestthing to paparazzi you encounter are the photo-ops of you and your girlfriends at club.) We've all heard the saying, "When in Rome, do as the Romans do." With the Moro Napa Roma Bagand Strappy Platform Sandals by [url=][/url] Bottega [url=][/url] Veneta, you can accomplish just that. The strappy details of the shoes are a contemporary take on traditional gladiator-style footwear, and the spacious woven tote keeps your belongings in check as you make your way toward the nearest trattoria. Fame and Fortune Cosmopolitan Chic Alexander McQueenaces this concept with their Folklore de Manta Clutchand Cut-out College Bootie. The contrast of the floral printagainst the details of the moremasculine mountaineer bootiebrings variety toan outfit, whilemaintaining arural (yet flirty) appeal. For decades, handbags and shoes have been renowned partners in crime; by complimenting one another, they unveil the hidden potential lurking behind many [url=]karen millen online[/url] underrated wardrobe staples. Fierce [url=][/url] footwear coupled with an equally chic bag creates such a successful tag-team duo due to their uncanny ability to bring balance to the eye. A smart way to achieve this harmony is by looking to a single designer for each of these fundamental accessory pieces.No matter how you accessorize-- either perfectly matched, orwith subtle [url=][/url] differences--we've gota few picks thataim tomirror thisbalance inyour next ensemble: Rebecca Minkoffunderstands thatpenciling in wardrobe changes in the middle ofourdaily routine isn't always a possibility, which is why theMorning After Clutch (MAC) andthe M.A.B. Cut-out Flatsin basic black make the perfect day-to-night twosome. For those who adore attention-grabbing accessories, Diane Von Furstenberghas theeclectic flair that keeps your closetstylish and unique. The bold print on thePenny Canvas Large Bagand Krista Printed Leather Sandalsmake the perfect statement piecesforyour favoritelittle black dress. Safari Sunset Vixen on Vacation Floral Expedition

  • people cup 2014 brazil soccer jerseys boonies exaltation coming this biggest soccer party.

    Posted by Merejensejage on 06/21/2013 06:04am

    Ferguson said: "We are delighted to have Rio fit again and back in contention. He's been having spasms and has missed the last [url=][/url] few games and that's given us an opportunity to get it settled down. Sir Alex Ferguson believes Rio Ferdinand's return to fitness will give his side a psychological edge going into Sunday's crucial clash with Chelsea at Old Trafford. Ferdinand has been missing for the champions since suffering back spasms in the middle of last month. United have coped well without the England defender but Ferguson knows his return for the visit of Chelsea is a huge boost ahead of a game that promises to influence the outcome of the title race. While Chelsea have spent millions since the arrival of Roman Abramovich, Ferguson insists he will not change his philosophy of building successful teams without breaking the bank at Old Trafford. Liverpool sit top on 45 points, with Chelsea three points adrift. United, with two games in hand, have 38 - a tally shared by fourth-placed Aston Villa. Ferguson added: "The two games in hand we [url=][/url] have gives us an opportunity to close the gap (on leaders Liverpool). There is no question those are important games and we have to take advantage of them. Ferguson has challenged United to make full use of their home advantage against Chelsea and take a significant step towards another Premier League title. United have enjoyed a successful season on home soil as well as having played Chelsea, Arsenal and Liverpool away from home. Ferguson, who has a fully fit squad to choose from with the exception of Wes Brown, knows his side can score another psychological victory over Chelsea with a win. "But we need to focus on the challenge of Chelsea first. Our home [url=]2014 world cup soccer jerseys[/url] form this season and record has been great again. Chelsea have always had a good record at Old Trafford. This is a big game and we need to meet the challenge." "He's trained for the past few days and feels fine. You always benefit from having your best players available and he's one of the best in the world. There's no question about that. We are lucky to have some good young players here to come in and replace him, but having Rio back makes [url=]brazil world cup jerseys[/url] a difference because of his stature and presence." He added: "Chelsea changed the face of the Premier League and to win the title back off them was important for us. We are building a team here that should last for a long time. We know we can't match the spending power of Chelsea and have to identify young players. [url=][/url] But it's about spending money the right way and finding the right balance for the team." Ferguson refused to be drawn on comments from Carlos Tevez that he is unhappy at United's stalling over contract talks. Tevez's public expression of frustration has reportedly infuriated the United boss but he was tight-lipped on Friday, insisting: "I'm not going to comment on players' contracts. It's a private matter between the player and the club."

  • Wat is er zo goed over hoofdtelefoon

    Posted by mrswanzi on 06/05/2013 08:34pm

    [url=]beats by dre[/url] Beats By Dre is domineert de hoofdtelefoon game al een tijdje, nu lijkt het alsof ze uit breidt naar de home audio markt met de introductie van de ¡®pil. ¡°De pil is een draagbare, draadloze luidspreker met een fantastisch geluid, net als de beats koptelefoon. Het beschikt over Bluetooth-mogelijkheden voor aansluitingen van maximaal 30 meter met een apparaat. Het beschikt ook over een interne microfoon die conference calls mogelijk maken. [url=]Beats by dre Goedkope[/url] Wanneer je echter muziek wil luisteren via een audiodrager zonder Bluetooth sluit je probleemloos alsnog een kabel aan. Via USB laat je de Beats by Dr. Dre Wireless in korte tijd weer op voor 10 uur luisterplezier. Geniet volledig in stijl en draadloos van je favoriete muziek met de Beats by Dr. Dre Wireless.De Beats Wireless levert net als alle andere Beats By Dr. Dre producten glasheldere hoge tonen, een natuurlijk middengebied en een krachtige strakke bas. Om ook via bluetooth de beste prestaties te kunnen leveren is de Beats Wireless voorzien van de laatste bluetooth technologien en geschikt voor ontvangst van AAC en APT-X signalen. Uiteraard is ook deze Beats voorzien van ControlTalk. [url=]beats by dre[/url] Om de fraaie hoofdtelefoon in topconditie te houden krijgt de gebruiker er ook een zacht poetsdoekje en een stevige beschermcase bij. En tenslotte wordt er ook een set AAA-batterijen meegeleverd voor direct luisterplezier. De Studio-hoofdtelefoons maken gebruik van noise canceling, waardoor omgevingsrumoer onderdrukt wordt. Alle modellen worden zeer compleet geleverd met twee kabels. Hiervan is er een voorzien van een gentegreerde microfoon en bedieningstoetsen voor gebruik met iOS-apparaten.

  • clarisonic pro with the cadaver whisk is sterling for me

    Posted by iouwanzi on 06/05/2013 08:34pm

    [url=]clarisonic mia online[/url] Hvis du interesserer lyden, hvordan man kan lytte til din musik, så vil du elske deBeats by Dr. Dre solo højtydende hovedtelefoner. Uanset om du er fagfolk eller entusiaster, de er den perfekte høj kvalitet at lytte til dig igen, hvis du interesserer lyd, hvordan du kan lytte til din musik på farten, så vil du elske beat af Dr. Dre Solo high-performance hovedtelefoner. Uanset om du er fagfolk eller entusiaster, de er perfekte, høj kvalitet lytter til dig på vejen. [url=]clarisonic classic[/url] Fordelene og ulemperne ved de forskellige typer af hovedtelefonerHeadset hovedtelefoner, takket være en større enhed, lydkvaliteten er mere bedre, men på grund af nogle store volumen, ikke er nem at bære. Ørepropper lille enhed design, kompakt og let at bære, velegnet til udendørs brug. Ørekrog øretelefon typen headset med ørepropper i mellem et smukt udseende, komfortable at bære, lyde bedre egenskaber end ørepropper ulempe er følsom over for støj udefra, som er egnet til at bære i foråret, og denne sæson . Forskellige typer hovedtelefoner er anderledes, for at se om du ønsker at bruge under hvilke omstændigheder. [url=]clarisonic pro[/url] BIII booo din troede involverer let jazz, med essentials involverer normal, god ole ‘, sammen med digitalkameraer sange for dig at lave en ny specifikt eksklusiv lyd. BIII øjeblikket omdefinerer private musik ekspertise til at gøre dine musikernes øretelefoner. Enhver observere, hver eneste nuance, kan optaget med aldrig-hørt-før realistisk look, plus iøjnefaldende design og stil trådløse høretelefoner bestemt ved en ny trompet mundstykke har som en installation vidnesbyrd om den mestre kunsten. Disse former for sædvanligvis er ikke kun de bedste ørepuder vedrørende jazz. Uanset hvad nogen hører, vil BIII sikkert vokset til betragtes som en af dine nuværende all-time musikalske teknologi højder.

  • It's been a rechannel week in role of comportment undistinguished retailer|egg on assuagement online

    Posted by SosseRourreli on 06/03/2013 04:27am

    The Best Laid Plans ELLE The Best Laid PlansMarch 26 12:02 PMby ELLE 0 Comments laughing hysterically at god-knows-what in my unplanned for red dress So I planned on wearing this little vintage gold backless minidress on my birthday forever. Or, you know, for the past couple of weeks. [url=][/url] Which is a pretty long time to plan on wearing something. Anyway, as I was getting ready to meet my friends for dinner on Saturday night, I pulled it on over my head, looked in the mirror....and realized that it was all wrong. Way too glittery and gold for a dinner [url=]coach factory[/url] and some East Village bar-hopping. So after a few panicked moments during which the entire contents of both of my closets ended up on my bedroom floor, I [url=][/url] settled on a tomato-red v-neck dress that I've had for years. Kind of a let-down but it just goes to show how even the simplest of plans can go totally awry. And then there are the bigger categories of [url=]coach outlet[/url] plans. Like [url=]coach factory[/url] the ones we make on New Year's Eve when we sit down and plan out who we're going to be in the next year, how we're going to be better, what we're going to do and when. Or for me, that always happens on birthdays. Another year older just seems more urgent to me than a new calendar year. So instead of New Year's resolutions, I make birthday resolutions. I come up with a game plan for what I'm going to accomplish in the year's time before I'm yet ANOTHER year older. My mental checklist of goals this year went something like this: Finish novel ASAP. Stop dating ridiculously inappropriate [url=]coach factory[/url] men. Stop dating ridiculously unavailable men. Stop smoking socially. Run five miles a day and eat less. Or at least eat healthier. So, okay, I broke two out of five about, oh, three hours into my birthday but I, um....did my best....? ANYway, I'm fully aware that most of these things are probably going to take a little more time and growing up than a year can provide but I just can't help making my little lists. I'm sure we all have a plan, a mental checklist that will comprise our perfect lives. But I'm also sure that no matter how diligently we design and classify and organize, it's pretty futile. Because we can strategize all we want, but when it comes down to it, they're just blueprints that don't take into account the unexpected. The unforeseen things, people, and events that can derail even the best laid plans. But we do the best we can. And in the end, that's all anyone can do. And besides, sometimes, those unexpected things, those blindsiding moments that you never see coming–sometimes those are exactly the ones that are really worth living for.

  • lululemon buying|lululemon canada how to be in the defeat ascendancy — don’t i long for to detritus here and castigate you that

    Posted by LecyLayelry on 06/03/2013 01:01am

    LeBron James' Yoga

  • wholesale jerseys from china

    Posted by Adarotupirrit on 05/06/2013 03:06pm

    NFL coaches and teams usually are mandating cost regarding time of year NFL lottery tickets. You will find very little sports adventures getting trialled now. Thus in theory enthusiasts haven't so much shed anything. Nevertheless using the NFLPA decertifying [url=]wholesale authentic jerseys[/url] as a union and the owners now in court, facing potential antitrust violations, it's safe to assume that the April 28-30 draft and free agency will be affected in some way.Cheap Texas Longhorns -Jerseys are actually snowed under utilizing autograph demands.With fans going crazy over the National Football Teams of Texas Longhorns, the Texas Longhorns jerseys are in high [url=][/url] demand everywhere. We sale high quality, Fans wear design jerseys online as a statement about which team they root for, and often get their favorite player's name on the back. Exactly what will probably end in losing the actual 2011 time of year? The leading situation with CBA talks features, and definately will possibly be, the actual fraction of NFL income to help battler incomes. Different big considerations comprise NFL [url=]wholesale authentic nfl T-Shirts [/url] rookie salaries and the legal inability of franchises to recoup signing bonuses from players who breach contracts or refuse to perform, NFL Game day live. In such contentious negotiations, it [url=][/url] is very difficult, and sometimes impossible, to determine which side has a better case.As professional sports activities player fans, usually you will buy some purchase NFL authentic jerseys at wholesale prices, even use it within the exact same color selection, style because you're chosen NFL team.

  • authentic nhl jerseys,thailand russia jersey

    Posted by enarvenow on 05/06/2013 12:19pm

    Messi once again saving the Barcelona micro-blog, they made it simpler for Barcelona triumph by simply scoring a couple of goals, and minimize the Barcelona attributable to the Winners Little league will be ill at ease outside frustration. The match up against Bettis, Barcelona stayed inadequate. Prior to the Messi play intended for Barcelona, Jesse Villa is going to be flattened the fico score only two -- only two, as well as the Argentina superstar along with his undisputed level, assist Barcelona secured the triumph. Juventus sits inside thirty-fifth Serie The League's 1-0 triumph on the Palermo, still left from the Little league three ahead of a couple of match up Key west 14 factors, ahead of defending achievements. [url=]cheap soccer shirts[/url] Prior to the referee blew the whistle, Juventus discipline Conti perhaps a bit stressed, continued the sidelines complain the reason why the referee failed to whack the whistle, needless to say the distance therefore in close proximity to Juventus discipline trophy, the spirits will be easy to understand, thinking that the seem implies that if you Wen ended up being ahead of defending the whistle blew, the main the judge right away converted into the seashore connected with enjoyment. The holders connected with Juventus devotees in addition played a large photo undoubtedly geared up 31 caps, the middle stadium in addition taken care of the endorsed team get ready to the substantial 31 crown great, devotees will be poured to the stadium while using workforce to be able to celebrate the name, Juventus online players could be to turn out to be the concentrate, base along with Lini, than alternative Juventus online players have 31 crown commemorative greeting card carnival, Captain Buffon in addition put on 31 crown commemorative T-shirt, devotees along with personnel include hurried onward to be able to larg along with kiss along with Buffon, at this point the stadium has been Carnival devotees "occupied", [url=]cheap soccer jerseys[/url] content we were holding keeping a variety of commemorative banners, the scene to be able to celebrate snap shots, keep for a long time aggregation not necessarily inside the center of the judge, as well as the persons from the holders is usually without any move forward through leaving behind, celebrate a further triumph. On the other hand, Juventus online players but not an excessive amount of to remain on the review, yet they're just from the locker space began his carnival, wine wanton spray shower space into madness, Juventus online players perhaps wearing shorts bare-skinned torso into battle, perhaps Conti ingest. After that from the locker space, Juve and will discipline Kong Diba simply briefs, along with put that, specifically to the swimming pool.

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date