0

Good day to you all. I am a beginner in the batch-file. Why doesn't my code want to work properly? In what direction to dig?

    for /F %%a in ('devcon driverfiles ^=net ^| find "PCI\"') do ( 
        devcon remove %%a
    )

Devcon give an error message

    for /F %%a in ('devcon driverfiles ^=net ^| find "PCI\"') do ( 
       devcon remove PCI\VEN_168C&DEV_0036&SUBSYS_020C1028&REV_01\4&7A7034C&0&00E2 
    )

If you directly set to for, it works correctly, why it happens? Devcon works correctly

Compo
  • 36,585
  • 5
  • 27
  • 39
MrHoj
  • 13
  • 2
  • 2
    1st avoid the default delims `for /f "delims="` 2nd double quote `"%%a"` to avoid the `&`-signs being interpreted as command concatenation. 3rd you do run the batch elevated? –  Aug 15 '19 at 11:20
  • 2
    I'm not sure why you've decided to use a [tag:for-loop] for this task when it looks as if it could be done directly, e.g. `devcon remove =net @pci\*` – Compo Aug 15 '19 at 12:48
  • @LotPings tried all your tips, in different variations. Unsuccessfully.. – MrHoj Aug 16 '19 at 04:31
  • @Compo Working option. `devcon remove PCI\*` It removes 10 devices instead of two. Thanks. I will think in this direction – MrHoj Aug 16 '19 at 04:41
  • @Compo Thanks. This works great for me. `devcon remove =net PCI\*` – MrHoj Aug 16 '19 at 04:49

0 Answers0