WinPE, Startnet.CMD and passing variables to second batch file not working
- by user140892
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