Tracy7011 Posted December 4, 2005 Share Posted December 4, 2005 'Just incase anyone needs an alternatvie to mapdrive.com found in this forum. 'mapdrive didn't work for me due to me wanting to make my second partition during install and I 'didn't know any of the disk numbers, volume numbers.'I used this last night on several machines and it worked good. Interesting, All the machines I have 'checked that have one cd, windows always calls them volume 0'From Topic:'Determine if CD-R drive exists'http://www.msfn.org/board/index.php?showtopic=60721&st=20'Ok, I am done with this now.'This script will:'1. find your cd-rom drive letter. '2. find the disk id of your hard disk'3. create a diskpart txt script file to a. remove the cd-rom drive letter, b. assign cd a letter (r: in my case)'c. create another partition on hard disk with remaining space and assign it letter e:'4. Creates a batch file that a. launches diskpart with the above script file b. formats the newly 'created partition. We have to do it from a batch due to diskpart runs in its own little command line and'want to know when it is complete so we can launch format as soon as it has created the partition.'I had to do this due to the systems we use at work need a e: partition and the cd at r:, we have a zip 'so windows always put the cd at defualt of e: and you can never know if windows will call the hard disk' disk 1 or disk 0.'I call this script from GuiRunOnce in Unattended with no support files.'************************DoDrives.vbs*********************Const FOR_READING = 1, FOR_WRITING = 2ComputerName = "."strComputer = "."Dim TFDIM NewFileDIM DefaultStringDIM CDDeviceIDDIM DiskNumDefaultString = Array ("select volume ", "remove noerr", "assign letter r", "select disk ", _"Create partition primary", "assign letter e", "exit")NewFile = "C:\install\Disk.txt" 'We have to create a .txt script file for diskpartNewBat = "C:\install\edrive.bat" 'We have to use a bat so we can launch format after we are done with diskpartSet objFSO = CreateObject("Scripting.FileSystemObject")Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _& strComputer & "\root\cimv2")Set colDisks = objWMIService.ExecQuery _("Select * from Win32_LogicalDisk")For Each objDisk in colDisksSelect Case objDisk.DriveTypeCase 1Case 2Case 3Case 4Case 5CDDeviceID = objDisk.DeviceIDCase 6Case ElseEnd SelectNextSet wmiServices = GetObject ( _"winmgmts:{impersonationLevel=Impersonate}!//" _& ComputerName)Set wmiDiskDrives = wmiServices.ExecQuery ( _"SELECT Caption, DeviceID FROM Win32_DiskDrive")For Each wmiDiskDrive In wmiDiskDrivesquery = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" _& wmiDiskDrive.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" Set wmiDiskPartitions = wmiServices.ExecQuery(query)For Each wmiDiskPartition In wmiDiskPartitionsSet wmiLogicalDisks = wmiServices.ExecQuery _("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" _& wmiDiskPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition") For Each wmiLogicalDisk In wmiLogicalDisksIf wmiDiskDrive.DeviceID = "\\.\PHYSICALDRIVE0" thenDiskNum="0"End IfIf wmiDiskDrive.DeviceID = "\\.\PHYSICALDRIVE1" thenDiskNum="1"End If Set TF=objfso.CreateTextFile(NewFile, True) 'Create a new script text fileTF.WriteLine (DefaultString(0)) & CDDeviceID 'select volume x: (x = CD Drive Letter)TF.WriteLine (DefaultString(1)) 'remove noerrTF.WriteLine (DefaultString(2)) 'assign letter rTF.WriteLine (DefaultString(3)) & DiskNum 'select disk x (0,1)TF.WriteLine (DefaultString(4)) 'Create partition primaryTF.WriteLine (DefaultString(5)) 'assign letter eTF.WriteLine (DefaultString(6)) 'exitTF.close 'Close the new fileSet TF=objfso.CreateTextFile(NewBat, True) 'Create a new batch fileTF.WriteLine "%windir%\system32\diskpart.exe /S c:\install\disk.txt > c:\install\drivelog.txt" 'This line launches diskpartTF.WriteLine "echo Y | %windir%\system32\format e: /fs:ntfs /q /v:""" 'This line formatsTF.close 'Close the new fileSet objShell = WScript.CreateObject("WScript.Shell")objShell.Run("%comspec% /K c:\install\edrive.bat"), 1, true 'Run the bat fileNextNextNext'''''End Code'''''Thanks gunsmokingman for putting the three scripts into one which led me making just one file to do it all. Link to comment Share on other sites More sharing options...
drscouse Posted December 4, 2005 Share Posted December 4, 2005 So what was mapdrive doing wrong...??? I am just curious, as I am a user of mapdrive, and given my system config, with 2 dvds, and 6 partitions... it works flawlessly for me. mdes, the developer was also very helpful in assisting with a few mods to make it work better for my config, however, the latest release works fine. Link to comment Share on other sites More sharing options...
Tracy7011 Posted December 5, 2005 Author Share Posted December 5, 2005 (edited) It kept telling me the cd rom was not reassignable. I am doing this on W2K, not sure if that is diff or not. I also didn't have the second partition built yet, I have an automated format cd that makes c: 4G and formats it. As I understood it, you need to add a file "drive.x" to each drive. e: is assinged to the cd after install, I need it R before I create my second partition e.Before I can make my partition I need to know what params to send to diskpart, (disk id). I then need to format it.I am sure mapdrive can do it and the problems I was having was mistakes on my part. But here is another way to do what I needed.Thanks for looking! Edited December 5, 2005 by Tracy7011 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now