|"Be careful that when trying to access certain (unused) driveletters, there is always a risc he may spawn the "Abort, Retry, Fail" message. The info is not a problem, but it can cause the script to hang, and that is an issue."|
Dir doesn't induce that problem, my guess is that it calls GetVolumeInformation with SetErrorMode using SEM_FAILCRITICALERRORS(0x0001). Both "GetVolumeInformation" and "SetErrorMode" are visible as plain text inside cmd.exe, presumably as imports.
If the "dir" fails the loop won't execute.