startnet.cmd: suppress 'System error 85' on duplicate Y: mount

The :prompt_waxtrace_asset picker block maps Y: to the enrollment share
so select-waxtrace-asset.ps1 can read INDEX.csv. The later :skip_machinenum
block also runs `net use Y: \\172.16.9.1\enrollment ...` to keep the share
mounted through the rest of imaging, but Y: is already mapped at that
point so the second net use throws "System error 85: The local device
name is already in use". Harmless (script proceeds and "the command
completed successfully" prints right after) but visible noise to the
operator during PXE imaging.

Gate the second net use behind `if exist Y:\` so we only map when Y: is
not already mounted. Same end state, no error message.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-05-22 09:38:34 -04:00
parent b86b830568
commit 45f39fd431

View File

@@ -211,11 +211,17 @@ echo Asset tag: %MACHINENUM%
:skip_machinenum
REM --- Map enrollment share early (kept open for copy after imaging) ---
REM Y: may already be mapped from :prompt_waxtrace_asset (picker block).
REM net use of an already-mapped letter throws "System error 85: The local
REM device name is already in use" which is harmless but noisy on screen.
REM Skip the re-map when Y: is already mounted.
set NEED_ENROLL=0
if not "%PPKG%"=="" set NEED_ENROLL=1
if not "%PCTYPE%"=="" set NEED_ENROLL=1
if "%NEED_ENROLL%"=="0" goto enroll_staged
if exist Y:\ goto enroll_already_mapped
net use Y: \\172.16.9.1\enrollment /user:pxe-upload pxe /persistent:no
:enroll_already_mapped
if "%PPKG%"=="" goto enroll_staged
if not exist "Y:\ppkgs\%SOURCE_PPKG%" (
echo WARNING: %SOURCE_PPKG% not found on server. Enrollment will be skipped.