Batch File to Search all drives for two files

February 21, 2011 at 12:48:51
Specs: Windows 7
I'm trying to right a batch file to search all drives for the ghost32.exe file and also to search all drives for the actual ghost file and once it finds both to actually run ghost to clone the machine and use the image file found. I need to replace the "d:\image.gho" with the path where the image file is actually found through the search because the drive letter may not always be "D". This will all be done from PE so I'm editing the startnet.cmd file in PE. Your help is greatly appreciated. This is what I have so far:

wpeinit

@echo off & setLocal EnableDELAYedeXpansion

for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%d: (
for /f "tokens=* delims= " %%a in ('dir/b %%d:\ghost32.exe 2^>nul') do (
"%%a" -clone,mode=load,src=d:\image.gho,dst=1
)
)
)

wpeutil reboot


Thanks again


See More: Batch File to Search all drives for two files

Report •

#1
February 21, 2011 at 13:35:01
i dont have a ghost exe or the scnario to test but i guess you can add a similer for loop serach for image.gho and when found assign that drive to a variable.
E.g below can be added.

for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%i:\image.gho set source=I:
echo image file found in drive %%I
)

later, modify your code to use %drive%: as source drive name..similer to

"%%a" -clone,mode=load,src=%drive%:\image.gho,dst=1


may be someone can come up with a better idea..

Subhash Chandra.


Report •

#2
February 22, 2011 at 14:04:06
Great! I got a similar response from a different site. Works great.

Thanks


Report •
Related Solutions


Ask Question