Jump to content

Optical drive variables & second CD install


Recommended Posts

To run a 2nd CD you will have to have an exact drive letter and path your CD-ROM in your batch file on the Windows XP CD.

This can be a problem if you decide to use your custom CD on another PC that may have different drive letters.

e.g. instead of %systemroot%\install\Applications, you will have to use X:\Applications\ (X:\ being the CD-ROM Drive)

You can use a variable to do this

So you will only have to change one line of code

Set CDRom2=X:

"%CDRom2%\extra path here" would equal

"X:\extra path here"

But this is still not good enough for me as I have a DVDRom and a CDRW.

I would like to put a cd in each drive and walk away!

(and have them eject at the appropriate times)

I am sure we could get a batch or something to seek out as many drives as we have and assign them to variables etc.

E.g. seach you computer for optical drives and automatically asign their drive letters to variables

I just don't have a lot of time atm!

Link to comment
Share on other sites


I have found the perfect tools for the job.

Look at

h**p://willowhayes.co.uk/

The program getcd.exe finds the drive letter of the first cdrom drive on the machine and can be used as a part of a batch file.

Thanks Oli for the great program!!!! :)

Link to comment
Share on other sites

Aaron,

Could you please put up step by step instructions on the unattended cd website how to incorporate the getcd program into the batch file. The batch should ask for the second cdrom and then continue to install the other programs directly from that cdrom without copoying them to the hard disk first.

I am sure that a lot of people want to add a lot of programs to their cd but cannot because of lack of space on the cd. This solution would solve all their problems.

I would then request you to add the instructions to the main website as well so that all may benefit.

Thanks.

:):D:rolleyes:

Link to comment
Share on other sites

here this will do it or you. and will handle 2 cdroms.

CLS
@ECHO OFF
SET CDROM=
IF EXIST D:\$OEM$\$1\install\First_boot.cmd SET CDROM=D:
IF EXIST E:\$OEM$\$1\install\First_boot.cmd SET CDROM=E:
IF EXIST F:\$OEM$\$1\install\First_boot.cmd SET CDROM=F:
IF EXIST G:\$OEM$\$1\install\First_boot.cmd SET CDROM=G:
IF EXIST H:\$OEM$\$1\install\First_boot.cmd SET CDROM=H:
IF EXIST I:\$OEM$\$1\install\First_boot.cmd SET CDROM=I:
IF EXIST J:\$OEM$\$1\install\First_boot.cmd SET CDROM=J:
IF EXIST K:\$OEM$\$1\install\First_boot.cmd SET CDROM=K:
ECHO.
IF EXIST %systemdrive%\install\hotfixes.cmd GOTO RUNCMD
ECHO If you only have one cdrom please remove your cd
ECHO from the cdrom and place the second cd in the drive.
ECHO.
ECHO If you have two cdroms then make sure your second
ECHO cd is in the second cdrom drive.
ECHO.
PAUSE
IF NOT EXIST %CDROM%\install\hotfixes.cmd GOTO RUNCMD

xcopy %CDROM%\install %systemdrive%\install\ /S /C /Q /H /Y
ECHO.

:RUNCMD
IF NOT EXIST %CDROM%\$OEM$\$1\install\First_boot.cmd GOTO RUNBATCH
ECHO Please remove your cd from the cdrom drive.
ECHO.
PAUSE
ECHO.
IF EXIST %CDROM%\$OEM$\$1\install\First_boot.cmd GOTO RUNCMD

:RUNBATCH
ECHO Running Main Batch ...
ECHO.
start /wait %systemdrive%\install\main_batch.cmd
:: load from second cd without intervention

IF NOT EXIST %systemdrive%\install\hotfixes.cmd GOTO APPS
ECHO Running Hotfixes Batch ...
ECHO.
start /wait %systemdrive%\install\hotfixes.cmd

:APPS
IF NOT EXIST %systemdrive%\install\applications.cmd GOTO CUSTOM
ECHO Running Applications Batch ...
ECHO.
start /wait %systemdrive%\install\applications.cmd

:CUSTOM
IF NOT EXIST %systemdrive%\install\CUSTOMIZE.CMD GOTO ERROR
ECHO Running Cumstom Batch ...
ECHO.
start /wait %systemdrive%\install\CUSTOMIZE.CMD  


:ERROR
IF NOT EXIST %systemdrive%\install\hotfixes.cmd GOTO _ECHO
IF NOT EXIST %systemdrive%\install\applications.cmd GOTO _ECHO
IF NOT EXIST %systemdrive%\install\CUSTOMIZE.CMD GOTO _ECHO
GOTO END

:_ECHO
ECHO.
ECHO *******************WARNING*******************
ECHO Hotfixes or Applications were not installed
ECHO because they could not be found.
ECHO.
ECHO Check %systemdrive%\install\install.log for
ECHO more information.
ECHO *******************WARNING*******************
ECHO.
PAUSE

:END
ECHO.
ECHO Restarting the PC in 1 minute...
shutdown -r -f -t 30 -c "Windows XP will now restart in 1 minute, this will give enough time for the shortcuts to update and for the shell to fully load before its ready to restart!"
ECHO.
::ECHO Deleting Temp Installation Files...
::RD /S /Q %systemdrive%\install
::RD /S /Q %systemdrive%\Drivers
::ECHO.
EXIT

Link to comment
Share on other sites

  • 2 weeks later...

That looks like a pretty good batch file there, but I'm a little bit confused by it...

I'm assuming that once you get to the point that the batch files are running, everything has already been copied to the hard drive... Or has it?

If it has, then I guess it tells you and you can insert your 2nd Cd-ROM and add whatever applications you need.... Right?

If you could drop a reply with some more info on that batch file, it'd be greatly appreciated!

Elkhound

Link to comment
Share on other sites

Yes look at it carefully it will check to see witch drive o=is your cdrom then it will copy all the files from the second cdrom to your hard drive. Then it starts to run the extra cmd files from the second cdrom as well as the ones from the first cdrom. Then it finishes everything off and does a reboot.

Link to comment
Share on other sites

  • 2 months later...
I have found the perfect tools for the job.

Look at

h**p://willowhayes.co.uk/

The program getcd.exe finds the drive letter of the first cdrom drive on the machine and can be used as a part of a batch file.

Thanks Oli for the great program!!!! :)

You're welcome. Sorry it took me so long to find you all!

Link to comment
Share on other sites

That's a good find pity it can't find all cd letters.

eg if I have two cdroms it could give back two variables (%cdrom%, and %cdrom2% etc)

I don't want much do I  :)

program GetCD;

{$APPTYPE CONSOLE}

uses

SysUtils,

classes,

Unit1 in 'Unit1.pas';

var

envlist: TStringList;

i: integer;

begin

writeln(getcd(getdisks)+':');

end.

--------

unit1.pas

--------

unit Unit1;

interface

uses classes, sysutils, windows;

function GetCD(availdisks: string): string;

function GetDisks:string;

implementation

function GetCD(availdisks: string): string;

var

i :integer;

root :pchar;

begin

result:=chr(0);

root:=stralloc(255);

for i:=1 to length(availdisks) do

begin

strpcopy(root,copy(availdisks,i,1)+':\');

if getdrivetype(root)=drive_cdrom then

begin

result:=availdisks;

break;

end;

end;

strdispose(root);

end;

function GetDisks:string;

var

availdisks: string;

i,n :integer;

buf :pchar;

begin

buf:=stralloc(255);

n:=GetLogicalDriveStrings(255,buf);

availdisks:='';

for i:=0 to n do

if buf<>#0 then begin

if (ord(buf) in [$41..$5a]) or (ord(buf) in [$61..$7a]) then

availdisks:=availdisks+upcase(buf)

end else

if buf[i+1]=#0 then

break;

strdispose(buf);

result:=availdisks;

end;

end.

Link to comment
Share on other sites

i found this somewhere else on this forum:

in cddrive.cmd:

@echo off

:start

for /F %%i IN ('dir /b %1:\win51') DO IF /I "%%i" == "win51" set CDDRIVE=%1:&& goto end

shift /1

goto start

:end

perhaps you'd like to change the file to be found (win51 in this example) on your second cd.

and call it in your batch:

CALL cddrive.cmd a b c d e f g h i j k l m n o p q r s t u v w x y z

this might be usefull. don't credit me for this, i forgot who posted it, sorry.

Note: the first space in CDDRIVE=%1: && goto end (in the original posted batch) made paths look like c: \windows so i removed it and it works fine now

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...