With newer laptops and desktops, our company's hardware is shipping more and more often with no CD rom, only the 1 hdd.

The issue is the C: shows up as a different Volume number depending on the presence of a CD Rom or not.  
This means i have to have 2 images that are identical less the first Pre Install task that creates the partition and formats the drive.

No CD Rom:
select disk 0
clean
create partition primary
select volume 0
assign letter="C"
format quick fs=ntfs
active
exit


Yes CD Rom:

select disk 0
clean
create partition primary
select volume 1
assign letter="C"
format quick fs=ntfs
active
exit



Is there anyway to give it a IF EXISTS style command to reduce these 2 tasks into one?


Something like:

IF EXISTS D: (GOTO yes) ELSE (GOTO no)
:yes
select disk 0
clean
create partition primary
select volume 1
assign letter="C"
format quick fs=ntfs
active
exit

:no
select disk 0
clean
create partition primary
select volume 0
assign letter="C"
format quick fs=ntfs
active
exit


I can't for the life of me find a command that will check for volume number, or volume type that will work in a IF command.  

The simple IF EXISTS D:\ doesn't work if there isn't a disk in the CD Rom.


Any help would be greatly appreciated.


1 Comment   [ + ] Show Comment

Comments

  • I've been looking around, and i might be able to do this with a VBS script from start to finish, but i have no experience with VBS. Anyone out there that can point me in the right direction?
Please log in to comment

Answers

0

I haven't tried this script in the K2000 but you can pipe it to a cmd find command to see if a cd-rom is present.


' DriveTypeList.vbs
' List drives and their type
' Script modified from 2 Microsoft script examples

Option Explicit
On Error Resume Next

WScript.Echo ShowDriveList

Function ShowDriveList
Dim fso, d, dc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
s = s & ShowDriveType(d) & vbCrLf
Next
ShowDriveList = s
End Function

Function ShowDriveType(drvpath)
Dim fso, d, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(drvpath)
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
ShowDriveType = "Drive " & d.DriveLetter & ": - " & t
End Function



Answered 07/30/2016 by: flip1001
Fourth Degree Green Belt

Please log in to comment
0
Hello,

I'm not sure that this is really necessary (think about if the cd rom drive is there or not I mean) but to answer to your question YES it is possible.
You need to create a zip file with the following files:
No_cd.txt that contains 
select disk 0
clean
create partition primary
select volume 1
assign letter="C"
format quick fs=ntfs
active
exit

Yes_cd.txt that contains:

select disk 0
clean
create partition primary
select volume 1
assign letter="C"
format quick fs=ntfs
active
exit

Decision.bat that contains:

IF EXISTS D: (GOTO yes) ELSE (GOTO no)
:yes
diskpart /s Yes_cd.txt

:no
diskpart /s No_cd.txt

Create a pre-installation task, type application and as payload use the zip file that contains all the 3 files.

The command line is simply Decision.bat

Kind regards,

Marco - StockTrader

Answered 02/24/2016 by: StockTrader
Red Belt

  • Its the IF EXISTS D: that is failing. It will only work if there is a CD in the drive. This is what i am trying to work around. A CD Drive with no CD in it.
Please log in to comment
0

If your KBE includes WMI commands (I can't recall if they are there by default or if you have to add them using KBE Manipulator), you can try something like this in place of the IF EXIST in StockTrader's example:

wmic logicaldisk get name | findstr /i /c:"D:" >nul
IF %ERRORLEVEL%==0 (GOTO yes) ELSE (GOTO no)

That lists all logical disk drives (including mapped drive letters) and checks to see if there is a D: drive among them.

Answered 02/25/2016 by: BHC-Austin
Fourth Degree Black Belt

Please log in to comment
Answer this question or Comment on this question for clarity