Jump to content

Recommended Posts

Posted

This is hard to decribe, but i need some help figuring out this batch file script. I know "or" is not the correct thing to use, and i was unsure about "else" as well.

All I am trying to do is make to batch determine if cd2 is present. If it is, then then it would run "RunOnceEx-2.cmd" off of cd1. If no cd2 is present, it would run "RunOnceEx-1.cmd" off of cd1. :)

cmdow @ /HID
@echo off

;Set Disk 1
IF EXIST D:\CD.txt set CDROM=D:
IF EXIST E:\CD.txt set CDROM=E:
IF EXIST F:\CD.txt set CDROM=F:
IF EXIST G:\CD.txt set CDROM=G:
IF EXIST H:\CD.txt set CDROM=H:
IF EXIST I:\CD.txt set CDROM=I:
IF EXIST J:\CD.txt set CDROM=J:

;What type of install RunOnceEx will be running
IF EXIST D:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST E:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST F:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST G:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST H:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST I:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd
IF EXIST J:\CD2.txt run %CDROM%\$OEM$\RunOnceEx-2.cmd or run %CDROM%\$OEM$\RunOnceEx-1.cmd

EXIT


Posted

@cmdow @ /HID
@echo off

REM Set Disk 1.
IF EXIST D:\CD.txt SET CDROM=D:
IF EXIST E:\CD.txt SET CDROM=E:
IF EXIST F:\CD.txt SET CDROM=F:
IF EXIST G:\CD.txt SET CDROM=G:
IF EXIST H:\CD.txt SET CDROM=H:
IF EXIST I:\CD.txt SET CDROM=I:

REM What type of install RunOnceEx will be running.
IF EXIST %CDROM%\CD2.txt %CDROM%\$OEM$\RunOnceEx-2.cmd ELSE %CDROM%\$OEM$\RunOnceEx-1.cmd

exit

That should do what you want. In this case, make sure CD2 has BOTH "CD.txt" AND "CD2.txt".

Posted

Thank you for you help, although I have encountered some problems with your script.

-> The variable sets CDROM to CD2, everytime (when CD.txt is on cd2, when it isn't the one cd install fails right away.). I had to put the RunOnceEx's on CD2, too.

-> It ONLY works with 2 CDs, I hoped it would be able to work for just on cd as well.

here is where I currently sit:

@echo off

IF EXIST D:\D1.txt SET CDROM=D:
IF EXIST E:\D1.txt SET CDROM=E:
IF EXIST F:\D1.txt SET CDROM=F:
IF EXIST G:\D1.txt SET CDROM=G:
IF EXIST H:\D1.txt SET CDROM=H:
IF EXIST I:\D1.txt SET CDROM=I:

IF EXIST D:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd
IF EXIST E:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd
IF EXIST F:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd
IF EXIST G:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd
IF EXIST H:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd
IF EXIST I:\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd

EXIT

Just tried it and it still doesn't work, i'll try yours again later.

Posted

On CD1, make sure you have "CD.txt" and "RunOnceEx-1.cmd".

On CD2, make sure you have "CD.txt", "CD2.txt" and "RunOnceEx-2.cmd".

That should work.

Posted
On CD1, make sure you have "CD.txt" and "RunOnceEx-1.cmd".

On CD2, make sure you have "CD.txt", "CD2.txt" and "RunOnceEx-2.cmd".

That should work.

I don't see how it possibly can work :)

1. if everything works right, When the batch runs, it would detect D1.txt (i changed the name) on CD1 first because it read it before CD2's D1.txt, right?

2. lets say %CDROM% is set to D:

3. Your scripts then tells it to look For D2.txt on disk 1, which will not be found because there is no D2.txt on disk 1.

4. so then it would run %CDROM%\$OEM$\RunOnceEx1.cmd, which is correct, if there is no disk 2.

the script needs to be able to see if disk two is inserted and then run RunOnceEx2 if there is a Disk2, or run RunOnceEx1 if there is not.

I think the script would have to look something like below. I tried it and it works fine for a 2cd install, but it just doesn't work for a 1cd, there are no errors, it just doesn't work. i

@echo off

IF EXIST D:\D1.txt SET CDROM=D:
IF EXIST E:\D1.txt SET CDROM=E:
IF EXIST F:\D1.txt SET CDROM=F:
IF EXIST G:\D1.txt SET CDROM=G:
IF EXIST H:\D1.txt SET CDROM=H:
IF EXIST I:\D1.txt SET CDROM=I:

IF EXIST D:\D2.txt SET CDROM2=D:
IF EXIST E:\D2.txt SET CDROM2=E:
IF EXIST F:\D2.txt SET CDROM2=F:
IF EXIST G:\D2.txt SET CDROM2=G:
IF EXIST H:\D2.txt SET CDROM2=H:
IF EXIST I:\D2.txt SET CDROM2=I:

IF EXIST %CDROM2%\D2.txt %CDROM%\$OEM$\RunOnceEx2.cmd ELSE %CDROM%\$OEM$\RunOnceEx1.cmd

EXIT

Posted

My script will work if you place the correct files on each CD.

Place "CD.txt" on CD1 AND CD2. Place "CD2.txt" on CD2.

Then:

@echo off

REM Set the CDRom drive letter (regardless of CD)...
IF EXIST D:\CD.txt SET CDROM=D:
IF EXIST E:\CD.txt SET CDROM=E:
IF EXIST F:\CD.txt SET CDROM=F:
IF EXIST G:\CD.txt SET CDROM=G:
IF EXIST H:\CD.txt SET CDROM=H:
IF EXIST I:\CD.txt SET CDROM=I:

REM Check if CD2.txt ALSO exists... If so, it must be CD2.
IF EXIST %CDROM%\CD2.txt (start /wait %CDROM%\$OEM$\RunOnceEx-2.cmd) ELSE start /wait %CDROM%\$OEM$\RunOnceEx-1.cmd

exit

Just make sure on CD1 you have "CD.txt" and CD2, you have "CD.txt" AND "CD2.txt"

Edit: There were some problems with this. The new version WILL work. Remember the ().

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