Problem with dynamically changing drive letters in WinPE

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Fugazi
Posts: 2
Joined: 01 Feb 2016 06:16

Problem with dynamically changing drive letters in WinPE

#1 Post by Fugazi » 01 Feb 2016 08:15

Hoping someone can help.

I am in the process of writing a bespoke DOS batch file (in WinPE) to run a windows imaging system. I require that the drive letters to all the partitions and the WinPE USB be set to specific ones, however when I change them using a DISKPART text file I get an unable to find path error.

Code: Select all

FOR %%i IN (C D E F G H I J K) DO IF EXIST %%i:\test.txt SET Drive=%%i: - Finds what drive the USB is in

ECHO SEL DISK 1 >> %Drive%\DP1.TXT
ECHO SEL PART 1 >> %Drive%\DP1.TXT
ECHO ASSIGN LETTER=W: >> %Drive%\DP1.TXT

DISKPART /S %Drive%\DP1.TXT

SET %Drive%=W:

DEL %Drive%\DP1.TXT

ECHO SEL DISK 0 > %Drive%\DP1.TXT
ECHO SEL PART 1 >> %Drive%\DP1.TXT
ECHO ASSIGN LETTER=V: >> %Drive%\DP1.TXT
ECHO REMOVE LETTER=V: >> %Drive%\DP1.TXT
ECHO SEL PART 2 >> %Drive%\DP1.TXT
ECHO ASSIGN LETTER=C: >> %Drive%\DP1.TXT
ECHO SEL PART 3 >> %Drive%\DP1.TXT
ECHO ASSIGN LETTER=Y: >> %Drive%\DP1.TXT
ECHO REMOVE LETTER=Y: >> %Drive%\DP1.TXT

DISKPART /S %Drive%\DP1.TXT


Everything runs fine up to the highlighted command, this is where I get the error, even though the DISKPART has been run and the USB drive letter has been changed.

With thanks

Fug
Last edited by Squashman on 01 Feb 2016 08:21, edited 1 time in total.
Reason: MOD EDIT: Please use code tags

Squashman
Expert
Posts: 4470
Joined: 23 Dec 2011 13:59

Re: Problem with dynamically changing drive letters in WinPE

#2 Post by Squashman » 01 Feb 2016 08:22

Code: Select all

SET %Drive%=W:

You do not use percent symbols when assigning a variable using the SET command. Remove the percent symbols.

Fugazi
Posts: 2
Joined: 01 Feb 2016 06:16

Re: Problem with dynamically changing drive letters in WinPE

#3 Post by Fugazi » 01 Feb 2016 09:01

Squashman wrote:

Code: Select all

SET %Drive%=W:

You do not use percent symbols when assigning a variable using the SET command. Remove the percent symbols.


Oh what a dumb so and so I am .. must have looked through that code 100 times and didn't see that.

Thank you.

Post Reply