1.

Solve : Batch File in WinPE?

Answer»

I am using a batch file to image machines using WinPE and Imagex. Currently I have a batch file which works on some machines but not on others. This is because the 2nd flash, which contains the Image file (filename.wim) is not always the same drive letter.

What I would like is for my batch file to find the drive using a search for the image file, then perform a DIR of this drive so that the filename is visible.

This is what I've written, but it doesn't seem to be working.
I look forward to your thoughts. THANKS!!

for %%i in (C D E F G H I J K) do if exist %%i:\*.wim set IMAGEDISK=%%i:
%IMAGEDISK%:
dirTo switch to a drive you need a letter and one colon.

Salmon...uh ok. Perhaps I haven't made this clear. I KNOW how to switch to a drive using one letter and one colon. HOWEVER, due to the way WinPE boots, the flash drive in question (along with other constraints) can be any of C, D, E, F, G, H, I etc. The LINES I have POSTED are what I am sure will find this drive letter for me. ( I have used this in other areas of the batch file to copy a particular file by name.)

So, again, I'm looking for someone with BATCH FILE experience in helping me debug these lines...

Does that say it better?Maybe I should have underlined or otherwise emphasised the word 'one'. I thought I'd lead you subtly to look at your CODE again, rather than jump right in and point out your glaring mistake. I see that was a waste of time. I have been writing batch files for MS-DOS since the early 1980s, and for the improved cmd.exe command interpreter since Windows 2000. I think that may count as "BATCH FILE EXPERIENCE". Since you felt inclined to get shouty in CAPITAL LETTERS I may be forgiven for a little sarcasm.

Here's your error:

I'll break down your script. Let's assume that the .wim file you are looking for is on drive G.

1.

for %%i in (C D E F G H I J K)

Iterate through those letters...

2.

do if exist %%i:\*.wim

... and for each one create an IF EXIST test, substituting each letter in turn for %%i, add a colon, a back slash, an asterisk, a dot and 'wim'. This test will be satisfied when %%i expands to G (when there is something that matches G:\*.wim) so...

3.

set IMAGEDISK=%%i:

now we create a variable called IMAGEDISK and set it equal to G plus a colon. See that colon? You should. You wrote it. At this stage %IMAGEDISK% will expand to G: OK? With me so far? Do stop me if this is getting too complex.

4. Now we are finished with the FOR command, and we go to the next line, where we find...

%IMAGEDISK%:

That is, the variable %IMAGEDISK% all ready to be expanded (to G: remember?), together with another (second) colon. Do you see that second colon? (Also written by you.) The effect of this is just the same as if you had written G:: instead.

A letter plus two colons will give rise to a syntax error.

The filename, directory name, or volume label syntax is incorrect.

That is why your script won't work.

Can I have an apology now please?

You can consider yourself very LUCKY I even bothered to reply after your GREAT rudeness.



Discussion

No Comment Found