microsoft / microsoft/Validation-OS
Unescaped parentheses in -AddedSWTargetDir break GenImage.cmd execution (\%~nxa was unexpected)
Nobody has claimed this yet.
- Dominant language
- Batchfile
- Stars
- 31
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
This issue was encountered on Validation OS 2026.07 (26100.8972.260722-1659.ge_release_svc_prod3_amd64fre_en-us_VALIDATIONOS.iso), running on a 25H2 host (10.0.26200.9267). I'm opening this issue here since there isn't another obvious place to provide VOS feedback; please let me know if it's best filed through Feedback Hub.
When specifying a target directory containing parentheses (such as \Program Files (x86)) using the -AddedSWTargetDir parameter, image generation fails during the custom software installation phase with the following batch parsing error:
\%~nxa was unexpected at this time.
In GenImage.cmd, the AddedSW processing block uses immediate % variable expansion instead of delayed expansion (!...!) within parenthesized blocks:
if defined AddedSW (
...
if defined AddedSWTargetDir set _OptionValue=%AddedSWTargetDir%
echo Added Software Target .. [!_OptionValue!]
)
for /f "tokens=*" %%a in (%AddedSWPathsFile%) do (
...
set TargetFolder=%AddedSWTargetDir%\%%~nxa
...
)
When %AddedSWTargetDir% is expanded at parse time, the ) in (x86) is interpreted as the closing delimiter of the for /f (or if) block, leaving \%%~nxa dangling and triggering a fatal parser syntax error in the latter case, and a display issue in the former case.
Steps to Reproduce
Run GenImage.cmd with custom software targeting \Program Files (x86):
GenImage.cmd -AddedSW:"C:\Path\To\MyTool" -AddedSWTargetDir:"\Program Files (x86)"
Suggested Fix
Switch variable evaluation to delayed expansion (!AddedSWTargetDir!) inside the parenthesized blocks:
In the options display block:
if defined AddedSWTargetDir set _OptionValue=!AddedSWTargetDir!
In the copy loop:
set TargetFolder=!AddedSWTargetDir!\%%~nxa
Workaround
Using the 8.3 short name avoids the issue on the user side (if 8.3 names are enabled in the partition flags):
-AddedSWTargetDir:"\PROGRA~2"
Alternatively, set the AddedSWTargetDir environment variable before invocation of GenImage.cmd:
set "AddedSWTargetDir=\Program Files (x86^)"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in GenImage.cmd and inspect the AddedSW options block and the for /f copy loop described in the issue. Reproduce with -AddedSWTargetDir:"\Program Files (x86)" and verify that image generation completes without the batch parsing error and that the target path is displayed and used correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100