Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
Outbreaker

{Batch] Find file on the CD-ROMs

Recommended Posts

THX the script works now. :D I used the GOTO command a lots in my 4 batch file but i thought the :EOF was the same as the quit command :ph34r:

The last script that i was testing was this one here it works the same as the VBScript only problem is that it has a little bug it wont give out the driver letter. :}

And is it also possible to do it that this batch script searches also in Fixed (Hard disk drives) and not only in the CD-ROM drives ?

This Script would be a good one to avoid the No Disk popup error on drives like the Floppy drive.

@ECHO OFF
FOR /F "tokens=1,2 delims=\" %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (
FOR /F "tokens=1,* delims=-" %%B IN ('fsutil fsinfo drivetype %%A^|FIND /I "CD-ROM"') do (
ECHO Checking drive %%B ...
IF EXIST "%%B\OEM\RunOnce\Auto Setup.bat" CALL "%%B\OEM\RunOnce\Auto Setup.bat"&GOTO :EOF
)
)
ECHO \OEM\RunOnce\Auto Setup.bat NOT FOUND
PAUSE

Edited by Outbreaker

Share this post


Link to post
Share on other sites

I have found the bug in the above script the - should be a space only.

But i could do a better script i needed only to removed this [->FSNAME='CDFS' AND <-} form the posted script by Yzöwl and now the script will search all drives for the file. :w00t:

This script is also better because it's querying the drives so there will be no popup error like "No Disk" that for example happens on the Floppy drive.


@ECHO OFF
SETLOCAL
(SET DRIVE=)
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^
"PATH='\\OEM\\RunOnce\\' AND FILENAME='Auto Setup' AND EXTENSION='bat'"^
GET Name /VALUE^|FIND "="`) DO SET "DRIVE=%%~d#"&SET "FPATH=%%#"
IF NOT DEFINED DRIVE GOTO :NO
IF DEFINED DRIVE GOTO :YES
:YES
ECHO File Found.
START "" "%FPATH%"
PAUSE
:NO
ECHO File Not Found.
PAUSE
ENDLOCAL

Edited by Outbreaker

Share this post


Link to post
Share on other sites

The last script that i was testing was this one here it works the same as the VBScript only problem is that it has a little bug it wont give out the driver letter. :}

And is it also possible to do it that this batch script searches also in Fixed (Hard disk drives) and not only in the CD-ROM drives ?

This Script would be a good one to avoid the No Disk popup error on drives like the Floppy drive.

Again, what the heck! :w00t: .

This:

fsutil fsinfo drivetype %%A^|FIND /I "CD-ROM"

searches ONLY for "CD-ROM" string.

If you just open a command prompt and type in it:

FOR /F "tokens=1,2 delims=\" %A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO fsutil fsinfo drivetype %A

[ENTER]

you should get an idea of what the output is (it depends on the language of your OS).

Most probably this would work:

@ECHO OFF
FOR /F "tokens=1,2 delims=\" %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (
FOR /F "tokens=1,* delims=-" %%B IN ('fsutil fsinfo drivetype %%A^|FIND /I /V "mov"') do (
ECHO Checking drive %%B ...
IF EXIST "%%B\OEM\RunOnce\Auto Setup.bat" (
CALL "%%B\OEM\RunOnce\Auto Setup.bat"
GOTO :EOF
) ELSE (
ECHO %%B\OEM\RunOnce\Auto Setup.bat NOT FOUND
)
)
)
ECHO \OEM\RunOnce\Auto Setup.bat NOT FOUND on ANY checked drive.
PAUSE

jaclaz

Share this post


Link to post
Share on other sites

Does someone know how to suppress this Message (No Instance(s) Available.) if the script has not found the file ? For now i use CLS the >NUL command i can't get to work on this script to suppress the message.


@ECHO OFF
SETLOCAL
(SET DRIVE=)
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^
"PATH='\\OEM\\RunOnce\\' AND FILENAME='Auto Setup' AND EXTENSION='bat'"^
GET Name /VALUE^|FIND "="`) DO SET "DRIVE=%%~d#"&SET "FPATH=%%#"
IF NOT DEFINED DRIVE GOTO :NO
IF DEFINED DRIVE GOTO :YES
:YES
ECHO File Found.
START "" "%FPATH%"
PAUSE
:NO
ECHO File Not Found.
PAUSE
ENDLOCAL

Share this post


Link to post
Share on other sites

@jaclaz

Your script works only if i set this

FORM:

delims=-"

TO:

delims= "

Could you explain how the script works because i don't get it what this is for [->^|FIND /I /V "mov"<-]

[EDIT]

Ok i found now out what the [->^|FIND /I /V "mov"<-] is for but this would works only on an Englisch windows so the WMIC script would be the best choice for this.

[/EDIT]

Edited by Outbreaker

Share this post


Link to post
Share on other sites

Does someone know how to suppress this Message (No Instance(s) Available.) if the script has not found the file ? For now i use CLS the >NUL command i can't get to work on this script to suppress the message.


@ECHO OFF
SETLOCAL
(SET DRIVE=)
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^
"PATH='\\OEM\\RunOnce\\' AND FILENAME='Auto Setup' AND EXTENSION='bat'"^
GET Name /VALUE^|FIND "="`) DO SET "DRIVE=%%~d#"&SET "FPATH=%%#"
IF NOT DEFINED DRIVE GOTO :NO
IF DEFINED DRIVE GOTO :YES
:YES
ECHO File Found.
START "" "%FPATH%"
PAUSE
:NO
ECHO File Not Found.
PAUSE
ENDLOCAL

Okay, I'm starting to get tired of this now!

Outbreaker, you asked for, in both the Title of this Topic and the first post, a solution specifically for a problem with files on CD-ROMS.

It appears to me that people have made an effort to provide you with solutions to match your request and all you have done is change their scripts to do something else and give your critique on them.

For example, the script above has taken a unique piece of code I produced for you, (I would go as far as to say that the method I used will very likely have not appeared anywhere else on the web), and ruined it. My first response in the Topic actually gives you what you've got around to requesting later on, it simply used a variable named %CDROM% and name CD-ROM, when it checked all drives not just optical ones!

Please ask for a soluion and accept its responses; if the solution doesn't work as is that's fair enough but do not change it, badly, to do something completely different and then criticize it. By the way, I see no reason to have my script altered in order to change the default message of 'No Instance(s) Available' for your preferred text string 'File Not Found'.

If you wish to use a script for something else either start a New Topic or politely request that the Topic Title is change to suit the new parameters and thank/apologise to those who have thus far helped with the previous remit.

Share this post


Link to post
Share on other sites

I have done a mistake in the Topic Title i wanted to write "{Batch] Search a file on the drives" if you can change the topic feel free to do it. ;)

You WMIC script is the best why to do it. And why i use "GOTO NO" is because i will point then to another section in the batch file it's not only to show this ECHO line :D

Edited by Outbreaker

Share this post


Link to post
Share on other sites
You WMIC script is the best why to do it. And why i use "GOTO NO" is because i will point then to another section in the batch file it's not only to show this ECHO line :D

I would doubt that it is given your new remit, not only can it's usefulness be impacted by the host OS, the major reason for it was due to the fact you stipulated CD-ROM drive, without that stipulation I'd not have ever suggested it.

I have done a mistake in the Topic Title i wanted to write "{Batch] Search a file on the drives" if you can change the topic feel free to do it. ;)

I'm fairly certain that the mistake you made was not in the Topic Title, but in the method you employed to get others to perform for you.

Topic Closed!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...