Jump to content

Install Nero if CDRW/DVDRW exist


Recommended Posts

Like the topic title says I want to automaticly install Nero if a CDRW or DVDRW drive is present in the system. Since we build a lot of systems and almost every system has a DVDRW or CDRW in it. Only a few don't have it so I want the preinstallation to automaticly skip Nero here.

The install stuff will be easy to make, only how can the preinstallation find out if theres a writer in the system? How to find that out in a cmd-box? Can someone point me to the right direction?

I want to do the same with PowerDVD, but thats project two ;)

Thanks in advance !

Link to comment
Share on other sites


I am not good programmer but here is the sloppy code.

hDevice = CreateFile("\\\\.\\F:",  // drive to open
                   GENERIC_READ | GENERIC_WRITE,
                   FILE_SHARE_READ |  FILE_SHARE_WRITE,
                   NULL,             // default security attributes
                   OPEN_EXISTING,    // disposition
                   0,                // file attributes
                   NULL);            // do not copy file attributes
if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
 {

   return (FALSE); //error handling
 }

bResult = DeviceIoControl(hDevice,  // device to be queried
     IOCTL_STORAGE_GET_MEDIA_TYPES_EX,  // operation to perform
                            NULL, 0, // no input buffer
                           obuff, sizeof(*obuff),     // output buffer
                           &rtnd,                 // # bytes returned
                           (LPOVERLAPPED) NULL);  // synchronous I/O

Now you will have

GET_MEDIA_TYPES struct

DeviceType dd ?

MediaInfoCount dd ?

MediaInfo DEVICE_MEDIA_INFO <>

GET_MEDIA_TYPES ends

at obuff.Its size depends on the capabilities of device.You have MediaInfoCount*DEVICE_MEDIA_INFO structure at that buffer which is union you have to parse according to its type.More info at MSDN.I have written some of the code but failed on parsing unions will try later if no one attempts:)

Link to comment
Share on other sites

If you are using a RunOnce.CMD or such, you could look for the appropriate driver of the cdrw/dvdrw, something like:

if NOT exist %systemroot%\system32\CD-driver.abc goto NoCD
start /wait Nero.exe
:NoCD

Of course if you install many brands or if the burner and non-burner use the same driver that might not help much...

Link to comment
Share on other sites

You could also use CDRECORD (which requires cygwin) to search for CD burners.

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

SET CDROM=
SET CDR=
FOR /F "SKIP=2 TOKENS=1,8 DELIMS=       '" %%A IN ('CDRECORD -scanbus') DO (
 IF /I "%%B" EQU " REMOVABLE CD-ROM" SET CDROM=!CDROM! "%%A"
)
ECHO CD Drives: %CDROM%

FOR %%X IN (%CDROM%) DO FOR /F "SKIP=2 DELIMS=" %%A IN ('CDRECORD -dev %%X -prcap') DO (
 IF /I "%%A" EQU "  DOES WRITE CD-R MEDIA" SET CDR=%%X
)
ECHO CD Burners: %CDR%

IF "%CDR%"="" GOTO NO_CDR
rem Install Nero


:NO_CDR

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...