{"id":1287,"date":"2010-09-16T14:54:01","date_gmt":"2010-09-16T12:54:01","guid":{"rendered":"https:\/\/www.peppercrew.nl\/?p=1287"},"modified":"2011-05-18T20:48:18","modified_gmt":"2011-05-18T19:48:18","slug":"change-driveletter-of-cd-rom","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/change-driveletter-of-cd-rom\/","title":{"rendered":"Change driveletter of CD-rom"},"content":{"rendered":"<div>In a deployment using Altiris (or any other deployment utility) it is common to change driveletters. Especially when servers are reinstalled once in a while, you probably encounter problems doing so using diskpart.<br \/>\nDiskpart is the utility supplied with Windows by Microsoft which enables you to manage you disks, partitions and volumes. One limitation is, however, that you&#8217;re unable to select a specific drive using filters. For instance a CD-rom drive.<\/div>\n<div>In an initial deployment you know how many disks there are and how many volumes. Because these are static you can create the diskpart script easily by specifying the disk ID or volume ID, which is numbered in the order of presence.<br \/>\nHowever, when you redeploy that same server this might be changed. If you&#8217;ve added a disk (or formatted it) the order of presence might be changed and the script will fail to execute the way you expected it.<br \/>\n<!--more--><br \/>\nIn order to &#8220;solve&#8221; this problem I wrote the following replacement batch script which sets the drive letter of the CD-Rom to the letter Z:. You can change the driveletter, filter or script to your needs.<br \/>\n<code><br \/>\n@Echo Off<br \/>\nREM Name\t\t: ChangeCDromDriveLetter.cmd<br \/>\nREM Author\t\t: I. Verheij - PepperByte<br \/>\nREM Description\t\t: Assigns a new drive letter to the last CD-rom found<br \/>\nREM Version\t\t: 0.1, 16-09-2010, Initial version<br \/>\nREM ------------------------------------------------------<\/code><\/div>\n<p><code><\/p>\n<div>REM Define the new drive letter of the CD-Rom<br \/>\nSET NewDrive=Z<\/div>\n<div>REM Lookup the drive letter of the CD-Rom<br \/>\nFOR \/F \"tokens=2 delims==\" %%A IN ('wmic cdrom get drive \/format:list^|find \"=\"') DO SET CurrentDrive=%%A<\/div>\n<div>REM Lookup the volume assigned to this driveletter<br \/>\nECHO LIST VOLUME&gt;\"%Temp%DiskpartListVolume\"<br \/>\nFOR \/F \"tokens=2,3 delims= \" %%A IN ('diskpart \/s \"%Temp%DiskpartListVolume\"^|find \"olume\"') DO If %%B==%CurrentDrive:~0,1% SET CDRomVolume=%%A<br \/>\nDEL \/Q \"%Temp%DiskpartListVolume\"<br \/>\nECHO Volume = %CdRomVolume%<\/div>\n<div>REM Assign the newe driveletter with DISKPART<br \/>\nECHO SELECT VOLUME %CDRomVolume% &gt;\"%TEMP%DiskPartChangeLetter\"<br \/>\nECHO ASSIGN LETTER=%NewDrive:~0,1%&gt;&gt;\"%TEMP%DiskPartChangeLetter\"<br \/>\nCALL DISKPART.EXE \/S \"%TEMP%DiskPartChangeLetter\"&gt;\"%TEMP%DiskPartOutput\"<br \/>\nDEL \/Q \"%TEMP%DiskPartChangeLetter\"<br \/>\nDEL \/Q \"%TEMP%DiskPartOutput\"<\/div>\n<div>REM Inform user<br \/>\nEcho The drive letter of the CD-Rom drive (volume %CDRomVolume%) has been changed from %CurrentDrive% to %NewDrive%:.<\/div>\n<p><\/code><\/p>\n<div>Edit 27-10-2010 : Remko Weijnen points me to his &#8220;<a href=\"https:\/\/www.remkoweijnen.nl\/blog\/2010\/10\/20\/change-driveletter-commandline-tool\/\">Change Driveletter Commandline Tool<\/a>&#8221; which gives the same result but without scripting.<\/div>\n<div>Ingmar Verheij<\/div>","protected":false},"excerpt":{"rendered":"<p>In a deployment using Altiris (or any other deployment utility) it is common to change driveletters. Especially when servers are reinstalled once in a while, you probably encounter problems doing so using diskpart. Diskpart is the utility supplied with Windows by Microsoft which enables you to manage you disks, partitions and volumes. One limitation is, [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[289],"tags":[219,220,221,222,223,224,225,226],"class_list":["post-1287","post","type-post","status-publish","format-standard","hentry","category-deployment-others","tag-altiris","tag-cd-rom","tag-cdrom","tag-command-line","tag-deployment","tag-drive-letter","tag-sccm","tag-script"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=1287"}],"version-history":[{"count":2,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1287\/revisions"}],"predecessor-version":[{"id":2292,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1287\/revisions\/2292"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=1287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=1287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=1287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}