0

I don't know scripting or PowerShell (yes I need to learn something). I'm not an expert batch file maker either.

I have a WinPE flash drive which I used to deploy OS images. I have the WIM, drivers and anything needed else outside the WinPE environment to ensure that Updates, changes are easier for me to make.

I use the "STARTNET.CMD" batch file which is part of the WinPE.

The reason to go through the letter drives is that the WinPE always gets the X letter drive assigned. The flash drive itself can receive a random letter which always changes.

My deployment menu is located on the flash drive it self and not inside the WinPE. This is so that if I need to make a change I don't have to re-do the WinPE.

I am able to locate the "menu.bat" batch file and launch it. I use a variable to capture the letter drive. I call the second batch file named "menu.bat" and pass the variable to it.

When the second batch file loads, I believe that I am calling the variable correctly. If I break out of the batch file I can echo the variable and see the expected reply. The issue is that I can't use the variable to work with anything on the second batch file. In my test, I can get this to work over and over. When it runs from the real USB flash drive it does not work. I removed comments from the second batch file to make it smaller.

My issue is that files below all get a message stating that the system cannot find the path specified.

Diskpart
Imagex.exe
bcdboot.exe

Why can't I get the varible to properly function when I try to using example "ImageX.exe"?

Contents of the Startnet.cmd

@echo off
for %%p in (a b 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 %%p:\Tools\ set w=%%p
Set execpatch=%w%\Tools\
call %w%:\Menu.bat \Tools\

Contents of the Menu.BAT

@echo off
set SecondPath=%1
cls
:Start
cls
Echo.
Echo.==============================================================
Echo. Windows 7 64 Bit Ent Basic Desktops
Echo.==============================================================
Echo.
Echo A. 790 Windows 7 - Basic
Echo.
Echo.
Echo I. Exit
Echo.
Echo.

set /p choice=Choose your option = 

if not '%choice%'=='' set choice=%choice:~0,1%

if '%choice%'=='a' goto 790_Windows_7_Basic

echo "%choice%" is not a valid (answer/command)
echo.

goto start
:790_Windows_7_Basic

REM DISKPART /s %SecondPath%BatchFiles\Make-Partition.txt

%SecondPath%imagex.exe /apply %SecondPath%Images\Win7-64b-Ent-Basic-SysPreped.wim 1 o:\ /verify

%SecondPath%bcdboot.exe o:\Windows /s S:

Copy %SecondPath%Unattended\unattend.XML o:\Windows\System32\sysprep\unattend.XML /y

xcopy %SecondPath%Drivers\790\*.* o:\Windows\INF\790\ /E /Q /Y

MD o:\Windows\Setup\Scripts\
Copy %SecondPath%BatchFiles\SetupComplete.cmd o:\Windows\Setup\Scripts\ /y

Goto Done

:Done
Exit
1
  • Welcome to Super User! Please take care to format your posts correctly. Insert code, select it and press Ctrl-K to indent it so it is shown as code. For the future, check our formatting help.
    – slhck
    Jun 18, 2012 at 17:36

3 Answers 3

0

From the looks of it, the last line in your startnet.cmd file should be

call %w%:\Menu.bat %w%:\Tools\

since menu.bat is apparently expecting the first argument to be the complete path to the Tools directory, including the drive letter.

Note that startnet.cmd sets an environment variable named w which menu.bat could use (but currently doesn't!) so another solution would be to replace all the instances of %SecondPath% with %w%:%SecondPath%.

2
  • What did end up working was to use:
    – LunchBox
    Jun 19, 2012 at 19:11
  • What did work was to end up using the first variable that I set. The first variable is called %MainPath% and was recommended by a co-worker to pass that variable to the second batch file but sue a different name for the vairable to prevent confusion. Well, that did not work but what did work was to se: %MainPatch%\Images*.wim etc. I will test as you suggestion though for my own knowledge. Thanks
    – LunchBox
    Jun 19, 2012 at 19:16
0

Does using Setx help? It modifies the user or system environment environment. Look at Setx /? for more

1
  • Never heard of that command but it should pretty good. I will test with it - thanks
    – LunchBox
    Jun 19, 2012 at 19:19
0

You should check "\sources\boot.wim" file, open this file, and then check these "\tools\imagex.exe and bcdboot.exe" files have correct directory in boot.wim.

1
  • yes everything is in the correct directory and if I run all manually it works. Is the batch file that does not. Harry Johnson's response actually helped solve my issue
    – LunchBox
    Jun 19, 2012 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .