0

I'm looking for a way to call upon the path of a file that is located on a USB drive where the letter may change depending upon the PC it is inserted into. This is for unattend.xml file under the FirstLogonCommands.

  <SynchronousCommand wcm:action="add">
        <Order>2</Order>
        <CommandLine>netsh wlan add profile filename="E:\Wi-Fi-Example.xml"</CommandLine>
  </SynchronousCommand>

(Not sure if it matters but I use one USB drive with the Windows install and another USB drive for answer files)

Rdavis
  • 1
  • 2
    Have you considered running your netsh command as an argument to cmd.exe, where you could first poll the available drives for one with your file in its root. For example: `cmd.exe /Q /C For /F %G In ('mountvol.exe ^^^| findstr.exe [C-Z]:\\') Do If Exist "%GWi-Fi-Example.xml" netsh.exe WLAN Add Profile Filename="%~dG\Wi-Fi-Example.xml"`. Obviously if you wanted to include drives A: and B:, which are rarely used these days, you could change `[C-Z]` to `[A-Z]`. – Compo Jun 16 '21 at 20:39
  • @KJ, the question is specific about locating a removable drive, and I'll be honest, but I don't really see how drives would already be mapped during that stage of an unattended Operating System setup. In addition, it should be obvious that there shouldn't be multiple different files with that same name in the root of more than one drive anyhow. – Compo Jun 16 '21 at 21:55
  • @Compo Your first response was exactly what I was looking for, I tried quite a few things before coming here to ask a question to include research. I just tweaked it to D-Z since my AutoUnattend creates the C Drive – Rdavis Jun 17 '21 at 13:27

0 Answers0