Repository: pypa/virtualenv

Issue:
Several cmd.exe windows spawned when running virtualenv on Windows
**Issue**

When virtualenv is run for the first time, multiple extra cmd.exe windows appear on the screen for a while.

This is probably easier to explain with a screencast: https://d.pr/v/yQMzXY

I assume those are used to check setuptools, pip, and wheel updates.


**Environment**

Provide at least:
- OS: Windows
- ``pip list`` of the host python where ``virtualenv`` is installed:

  ```
  Package    Version
  ---------- -------
  appdirs    1.4.3
  distlib    0.3.1
  filelock   3.0.12
  pip        20.2.2
  setuptools 49.6.0
  six        1.14.0
  virtualenv 20.0.31
  wheel      0.35.1
  ```

**Output of the virtual environment creation**

Make sure to run the creation with `-vvv --with-traceback`:

<details>

```
152 setup logging to NOTSET [DEBUG report:43]
152 created app data folder C:\Users\uranusjr\AppData\Local\pypa\virtualenv [DEBUG __init__:30]
166 find interpreter for spec PythonSpec(path=c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\scripts\python.exe) [INFO builtin:44]
169 Attempting to acquire lock 1542576898112 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\py_info\1\ea7bf2eee3ed67557d64b592a1f73b5ed2dd9edb961e1fbe933fe0503584d4fe.lock [DEBUG filelock:270]
171 Lock 1542576898112 acquired on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\py_info\1\ea7bf2eee3ed67557d64b592a1f73b5ed2dd9edb961e1fbe933fe0503584d4fe.lock [INFO filelock:274]
171 get interpreter info via cmd: 'C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe' 'c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\lib\site-packages\virtualenv\discovery\py_info.py' [DEBUG cached_py_info:87]
322 wrote python info of C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe at C:\Users\uranusjr\AppData\Local\pypa\virtualenv\py_info\1\ea7bf2eee3ed67557d64b592a1f73b5ed2dd9edb961e1fbe933fe0503584d4fe.json [DEBUG via_disk_folder:159]
322 Attempting to release lock 1542576898112 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\py_info\1\ea7bf2eee3ed67557d64b592a1f73b5ed2dd9edb961e1fbe933fe0503584d4fe.lock [DEBUG filelock:315]
323 Lock 1542576898112 released on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\py_info\1\ea7bf2eee3ed67557d64b592a1f73b5ed2dd9edb961e1fbe933fe0503584d4fe.lock [INFO filelock:318]
323 proposed PythonInfo(spec=CPython3.8.1.final.0-64, system=C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe, exe=c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\scripts\python.exe, platform=win32, version='3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-cp1252) [INFO builtin:50]
323 accepted PythonInfo(spec=CPython3.8.1.final.0-64, system=C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe, exe=c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\scripts\python.exe, platform=win32, version='3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-cp1252) [DEBUG builtin:52]
331 symlink on filesystem does not work [DEBUG info:47]
331 filesystem is not case-sensitive [DEBUG info:28]
424 create virtual environment via CPython3Windows(dest=C:\Users\uranusjr\test, clear=False, global=False) [INFO session:52]
425 write C:\Users\uranusjr\test\pyvenv.cfg [DEBUG pyenv_cfg:34]
425     home = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
425     implementation = CPython [DEBUG pyenv_cfg:38]
425     version_info = 3.8.1.final.0 [DEBUG pyenv_cfg:38]
425     virtualenv = 20.0.31 [DEBUG pyenv_cfg:38]
426     include-system-site-packages = false [DEBUG pyenv_cfg:38]
426     base-prefix = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
426     base-exec-prefix = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
426     base-executable = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe [DEBUG pyenv_cfg:38]
427 remove file C:\Users\uranusjr\test\Scripts\python.exe [DEBUG _sync:38]
428 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe to C:\Users\uranusjr\test\Scripts\python.exe [DEBUG _sync:52]
430 remove file C:\Users\uranusjr\test\Scripts\pythonw.exe [DEBUG _sync:38]
431 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\pythonw.exe to C:\Users\uranusjr\test\Scripts\pythonw.exe [DEBUG _sync:52]
433 remove file C:\Users\uranusjr\test\Scripts\python3.dll [DEBUG _sync:38]
434 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python3.dll to C:\Users\uranusjr\test\Scripts\python3.dll [DEBUG _sync:52]
436 remove file C:\Users\uranusjr\test\Scripts\python38.dll [DEBUG _sync:38]
439 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python38.dll to C:\Users\uranusjr\test\Scripts\python38.dll [DEBUG _sync:52]
445 remove file C:\Users\uranusjr\test\Scripts\vcruntime140.dll [DEBUG _sync:38]
445 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\vcruntime140.dll to C:\Users\uranusjr\test\Scripts\vcruntime140.dll [DEBUG _sync:52]
447 remove file C:\Users\uranusjr\test\Scripts\libcrypto-1_1.dll [DEBUG _sync:38]
448 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\libcrypto-1_1.dll to C:\Users\uranusjr\test\Scripts\libcrypto-1_1.dll [DEBUG _sync:52]
452 remove file C:\Users\uranusjr\test\Scripts\libffi-7.dll [DEBUG _sync:38]
452 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\libffi-7.dll to C:\Users\uranusjr\test\Scripts\libffi-7.dll [DEBUG _sync:52]
455 remove file C:\Users\uranusjr\test\Scripts\libssl-1_1.dll [DEBUG _sync:38]
456 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\libssl-1_1.dll to C:\Users\uranusjr\test\Scripts\libssl-1_1.dll [DEBUG _sync:52]
460 remove file C:\Users\uranusjr\test\Scripts\pyexpat.pyd [DEBUG _sync:38]
460 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\pyexpat.pyd to C:\Users\uranusjr\test\Scripts\pyexpat.pyd [DEBUG _sync:52]
462 remove file C:\Users\uranusjr\test\Scripts\select.pyd [DEBUG _sync:38]
463 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\select.pyd to C:\Users\uranusjr\test\Scripts\select.pyd [DEBUG _sync:52]
465 remove file C:\Users\uranusjr\test\Scripts\sqlite3.dll [DEBUG _sync:38]
466 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\sqlite3.dll to C:\Users\uranusjr\test\Scripts\sqlite3.dll [DEBUG _sync:52]
470 remove file C:\Users\uranusjr\test\Scripts\tcl86t.dll [DEBUG _sync:38]
471 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\tcl86t.dll to C:\Users\uranusjr\test\Scripts\tcl86t.dll [DEBUG _sync:52]
474 remove file C:\Users\uranusjr\test\Scripts\tk86t.dll [DEBUG _sync:38]
475 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\tk86t.dll to C:\Users\uranusjr\test\Scripts\tk86t.dll [DEBUG _sync:52]
479 remove file C:\Users\uranusjr\test\Scripts\unicodedata.pyd [DEBUG _sync:38]
480 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\unicodedata.pyd to C:\Users\uranusjr\test\Scripts\unicodedata.pyd [DEBUG _sync:52]
484 remove file C:\Users\uranusjr\test\Scripts\winsound.pyd [DEBUG _sync:38]
484 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\winsound.pyd to C:\Users\uranusjr\test\Scripts\winsound.pyd [DEBUG _sync:52]
486 remove file C:\Users\uranusjr\test\Scripts\_asyncio.pyd [DEBUG _sync:38]
487 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_asyncio.pyd to C:\Users\uranusjr\test\Scripts\_asyncio.pyd [DEBUG _sync:52]
489 remove file C:\Users\uranusjr\test\Scripts\_bz2.pyd [DEBUG _sync:38]
490 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_bz2.pyd to C:\Users\uranusjr\test\Scripts\_bz2.pyd [DEBUG _sync:52]
492 remove file C:\Users\uranusjr\test\Scripts\_ctypes.pyd [DEBUG _sync:38]
492 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_ctypes.pyd to C:\Users\uranusjr\test\Scripts\_ctypes.pyd [DEBUG _sync:52]
494 remove file C:\Users\uranusjr\test\Scripts\_decimal.pyd [DEBUG _sync:38]
495 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_decimal.pyd to C:\Users\uranusjr\test\Scripts\_decimal.pyd [DEBUG _sync:52]
497 remove file C:\Users\uranusjr\test\Scripts\_elementtree.pyd [DEBUG _sync:38]
498 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_elementtree.pyd to C:\Users\uranusjr\test\Scripts\_elementtree.pyd [DEBUG _sync:52]
500 remove file C:\Users\uranusjr\test\Scripts\_hashlib.pyd [DEBUG _sync:38]
502 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_hashlib.pyd to C:\Users\uranusjr\test\Scripts\_hashlib.pyd [DEBUG _sync:52]
504 remove file C:\Users\uranusjr\test\Scripts\_lzma.pyd [DEBUG _sync:38]
505 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_lzma.pyd to C:\Users\uranusjr\test\Scripts\_lzma.pyd [DEBUG _sync:52]
510 remove file C:\Users\uranusjr\test\Scripts\_msi.pyd [DEBUG _sync:38]
511 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_msi.pyd to C:\Users\uranusjr\test\Scripts\_msi.pyd [DEBUG _sync:52]
515 remove file C:\Users\uranusjr\test\Scripts\_multiprocessing.pyd [DEBUG _sync:38]
516 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_multiprocessing.pyd to C:\Users\uranusjr\test\Scripts\_multiprocessing.pyd [DEBUG _sync:52]
518 remove file C:\Users\uranusjr\test\Scripts\_overlapped.pyd [DEBUG _sync:38]
518 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_overlapped.pyd to C:\Users\uranusjr\test\Scripts\_overlapped.pyd [DEBUG _sync:52]
521 remove file C:\Users\uranusjr\test\Scripts\_queue.pyd [DEBUG _sync:38]
522 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_queue.pyd to C:\Users\uranusjr\test\Scripts\_queue.pyd [DEBUG _sync:52]
524 remove file C:\Users\uranusjr\test\Scripts\_socket.pyd [DEBUG _sync:38]
525 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_socket.pyd to C:\Users\uranusjr\test\Scripts\_socket.pyd [DEBUG _sync:52]
528 remove file C:\Users\uranusjr\test\Scripts\_sqlite3.pyd [DEBUG _sync:38]
528 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_sqlite3.pyd to C:\Users\uranusjr\test\Scripts\_sqlite3.pyd [DEBUG _sync:52]
530 remove file C:\Users\uranusjr\test\Scripts\_ssl.pyd [DEBUG _sync:38]
531 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_ssl.pyd to C:\Users\uranusjr\test\Scripts\_ssl.pyd [DEBUG _sync:52]
533 remove file C:\Users\uranusjr\test\Scripts\_tkinter.pyd [DEBUG _sync:38]
534 copy C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\DLLs\_tkinter.pyd to C:\Users\uranusjr\test\Scripts\_tkinter.pyd [DEBUG _sync:52]
536 create virtualenv import hook file C:\Users\uranusjr\test\Lib\site-packages\_virtualenv.pth [DEBUG api:94]
537 create C:\Users\uranusjr\test\Lib\site-packages\_virtualenv.py [DEBUG api:97]
538 ============================== target debug ============================== [DEBUG session:54]
538 debug via 'C:\Users\uranusjr\test\Scripts\python.exe' 'c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\lib\site-packages\virtualenv\create\debug.py' [DEBUG creator:209]
538 {
  "sys": {
    "executable": "C:\\Users\\uranusjr\\test\\Scripts\\python.exe",
    "_base_executable": "C:\\Users\\uranusjr\\test\\Scripts\\python.exe",
    "prefix": "C:\\Users\\uranusjr\\test",
    "base_prefix": "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38",
    "real_prefix": null,
    "exec_prefix": "C:\\Users\\uranusjr\\test",
    "base_exec_prefix": "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38",
    "path": [
      "C:\\Users\\uranusjr\\test\\Scripts\\python38.zip",
      "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38\\DLLs",
      "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38\\lib",
      "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38",
      "C:\\Users\\uranusjr\\test",
      "C:\\Users\\uranusjr\\test\\lib\\site-packages"
    ],
    "meta_path": [
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "cp1252"
  },
  "version": "3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]",
  "makefile_filename": "C:\\Users\\uranusjr\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\config\\Makefile",
  "os": "<module 'os' from 'C:\\\\Users\\\\uranusjr\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python38\\\\lib\\\\os.py'>",
  "site": "<module 'site' from 'C:\\\\Users\\\\uranusjr\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python38\\\\lib\\\\site.py'>",
  "datetime": "<module 'datetime' from 'C:\\\\Users\\\\uranusjr\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python38\\\\lib\\\\datetime.py'>",
  "math": "<module 'math' (built-in)>",
  "json": "<module 'json' from 'C:\\\\Users\\\\uranusjr\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python38\\\\lib\\\\json\\\\__init__.py'>"
} [DEBUG session:55]
760 add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\uranusjr\AppData\Local\pypa\virtualenv) [INFO session:59]
766 wrote embed update of distribution setuptools at C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\setuptools.json [DEBUG via_disk_folder:159]
766 wrote embed update of distribution pip at C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\pip.json [DEBUG via_disk_folder:159]
767 wrote embed update of distribution wheel at C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\wheel.json [DEBUG via_disk_folder:159]
770 triggered periodic upgrade of setuptools==49.6.0 (for python 3.8) via background process having PID 13968 [INFO periodic_update:191]
771 triggered periodic upgrade of pip==20.2.2 (for python 3.8) via background process having PID 2760 [INFO periodic_update:191]
773 triggered periodic upgrade of wheel==0.35.1 (for python 3.8) via background process having PID 10656 [INFO periodic_update:191]
788 got embed update of distribution setuptools from C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\setuptools.json [DEBUG via_disk_folder:133]
789 got embed update of distribution pip from C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\pip.json [DEBUG via_disk_folder:133]
789 got embed update of distribution wheel from C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\embed\1\wheel.json [DEBUG via_disk_folder:133]
799 install setuptools from wheel c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\lib\site-packages\virtualenv\seed\wheels\embed\setuptools-49.6.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
800 install pip from wheel c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\lib\site-packages\virtualenv\seed\wheels\embed\pip-20.2.2-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
801 install wheel from wheel c:\users\uranusjr\appdata\local\programs\pipx\venvs\virtualenv\lib\site-packages\virtualenv\seed\wheels\embed\wheel-0.35.1-py2.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:53]
802 Attempting to acquire lock 1542583620752 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any.lock [DEBUG filelock:270]
802 Attempting to acquire lock 1542583621184 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any.lock [DEBUG filelock:270]
803 Attempting to acquire lock 1542583621424 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:270]
803 Lock 1542583620752 acquired on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any.lock [INFO filelock:274]
804 Lock 1542583621184 acquired on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any.lock [INFO filelock:274]
805 build install image for setuptools-49.6.0-py3-none-any.whl to C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any [DEBUG base:52]
805 Lock 1542583621424 acquired on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:274]
805 build install image for pip-20.2.2-py2.py3-none-any.whl to C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any [DEBUG base:52]
809 build install image for wheel-0.35.1-py2.py3-none-any.whl to C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any [DEBUG base:52]
929 Attempting to release lock 1542583621424 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any.lock [DEBUG filelock:315]
932 Lock 1542583621424 released on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any.lock [INFO filelock:318]
942 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any\wheel to C:\Users\uranusjr\test\Lib\site-packages\wheel [DEBUG _sync:52]
1208 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any\wheel-0.35.1.dist-info to C:\Users\uranusjr\test\Lib\site-packages\wheel-0.35.1.dist-info [DEBUG _sync:52]
1275 Attempting to release lock 1542583620752 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any.lock [DEBUG filelock:315]
1278 Lock 1542583620752 released on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any.lock [INFO filelock:318]
1281 copy C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\distutils-precedence.pth to C:\Users\uranusjr\test\Lib\site-packages\distutils-precedence.pth [DEBUG _sync:52]
1320 copy C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\easy_install.py to C:\Users\uranusjr\test\Lib\site-packages\easy_install.py [DEBUG _sync:52]
1328 copy C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\wheel-0.35.1-py2.py3-none-any\wheel-0.35.1.virtualenv to C:\Users\uranusjr\test\Lib\site-packages\wheel-0.35.1.virtualenv [DEBUG _sync:52]
1354 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\pkg_resources to C:\Users\uranusjr\test\Lib\site-packages\pkg_resources [DEBUG _sync:52]
1354 generated console scripts wheel3.8.exe wheel3.exe wheel-3.8.exe wheel.exe [DEBUG base:48]
1625 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\setuptools to C:\Users\uranusjr\test\Lib\site-packages\setuptools [DEBUG _sync:52]
1809 Attempting to release lock 1542583621184 on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any.lock [DEBUG filelock:315]
1811 Lock 1542583621184 released on C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any.lock [INFO filelock:318]
1943 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any\pip to C:\Users\uranusjr\test\Lib\site-packages\pip [DEBUG _sync:52]
2896 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\setuptools-49.6.0.dist-info to C:\Users\uranusjr\test\Lib\site-packages\setuptools-49.6.0.dist-info [DEBUG _sync:52]
2946 copy C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\setuptools-49.6.0.virtualenv to C:\Users\uranusjr\test\Lib\site-packages\setuptools-49.6.0.virtualenv [DEBUG _sync:52]
2956 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\setuptools-49.6.0-py3-none-any\_distutils_hack to C:\Users\uranusjr\test\Lib\site-packages\_distutils_hack [DEBUG _sync:52]
2970 generated console scripts easy_install3.8.exe easy_install3.exe easy_install.exe easy_install-3.8.exe [DEBUG base:48]
4516 copy directory C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any\pip-20.2.2.dist-info to C:\Users\uranusjr\test\Lib\site-packages\pip-20.2.2.dist-info [DEBUG _sync:52]
4544 copy C:\Users\uranusjr\AppData\Local\pypa\virtualenv\wheel\3.8\image\1\CopyPipInstall\pip-20.2.2-py2.py3-none-any\pip-20.2.2.virtualenv to C:\Users\uranusjr\test\Lib\site-packages\pip-20.2.2.virtualenv [DEBUG _sync:52]
4557 generated console scripts pip3.8.exe pip.exe pip-3.8.exe pip3.exe [DEBUG base:48]
4558 add activators for Bash, Batch, Fish, PowerShell, Python, Xonsh [INFO session:64]
4564 write C:\Users\uranusjr\test\pyvenv.cfg [DEBUG pyenv_cfg:34]
4565    home = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
4565    implementation = CPython [DEBUG pyenv_cfg:38]
4565    version_info = 3.8.1.final.0 [DEBUG pyenv_cfg:38]
4565    virtualenv = 20.0.31 [DEBUG pyenv_cfg:38]
4565    include-system-site-packages = false [DEBUG pyenv_cfg:38]
4566    base-prefix = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
4566    base-exec-prefix = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38 [DEBUG pyenv_cfg:38]
4566    base-executable = C:\Users\uranusjr\AppData\Local\Programs\Python\Python38\python.exe [DEBUG pyenv_cfg:38]
4567 created virtual environment CPython3.8.1.final.0-64 in 4421ms
  creator CPython3Windows(dest=C:\Users\uranusjr\test, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\uranusjr\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator [WARNING __main__:17]
```

</details>


Discussion:
This is true, but I'm not sure what's your proposal as alternative. This works as designed. 
Can the windows be hidden? It's a background task, so should not pop up windows in the foreground.
It should be possible to not show the windows. But the question is, why are there windows to show in the first place?<sup>note</sup> Normal subprocess calls use the CreateProcess API, and shouldn’t spawn a shell  (which causes a window to show) at all.

<sup>note</sup> I did not read the implementation in virtualenv.
The implementation uses `DETACHED_PROCESS`, and this seems to be the issue. The following simple reproducing case demonstrates the issue for me:

```python
from subprocess import DETACHED_PROCESS, Popen
p = Popen(["py", "-c", "from time import sleep; sleep(5)"], creationflags=DETACHED_PROCESS)
```

The relevant virtualenv code is [here](https://github.com/pypa/virtualenv/blob/master/src/virtualenv/seed/wheels/periodic_update.py#L189).
I can’t say I understand the myriad of process and window flags in Win32 API, but if the process must be launched detached, I believe there are flags to hide/disable the window as well.
Trying those, they don't seem to work 🙁 

It seems to be somehow related to the chain of processes involved, as using `sys.executable` rather than `py` in my sample code shows no window. Virtualenv uses `sys.executable` but maybe it's related to how *virtualenv* is called. I often use `pew` which calls virtualenv under the hood. That may be relevant here. @uranusjr do you run virtualenv via a wrapper?
@zooba do you happen to know the magic incantation to run a detached process without a new window showing up? It's crucial that this process runs detached because the upgrade can take a long time, a lot longer than the virtual environment creation.
> @uranusjr do you run virtualenv via a wrapper?

I call virtualenv.exe installed with pipx, so yeah, there are quite some indirections involved. virtualenv.exe is a wrapper that calls the venv python.exe, which is itself a wrapper (venvlauncher.exe) to the “real” python.exe.

> It's crucial that this process runs detached because the upgrade can take a long time, a lot longer than the virtual environment creation.

Makes sense, thanks for the additional context.

---

I’ll try some flag combinations myself as well and report back if I make any process. If all else fail, maybe it’d be doable to special-case Windows and launch `pythonw.exe` instead of `python.exe` instead?
I've raised https://bugs.python.org/issue41619 because I think the inconsistent behaviour at least needs better explanation. I suspect that the launcher is part of the issue here - the Python 3 virtual environment mechanism uses a modified version of the launcher (although I don't know if virtualenv uses that mechanism or has its own approach). Unfortunately, the details of that mechanism are undocumented, so it's hard to know what's intended and what's accidental...

I think that even if there is a bug in Python here, virtualenv should work around it as the extra windows are not ideal. Hopefully the bug report will at least result in a more detailed explanation of what's going on here which will help us work out how to avoid them.
> I think that even if there is a bug in Python here, virtualenv should work around it as the extra windows are not ideal.

At this point I'm not aware that's possible for virtualenv to work around it. I'm happy to workaround if somone provides a way to work around it in a reliable way.
From the bpo issue, it looks like `CREATE_NO_WINDOW` (0x8000000) works, but it must be specified instead of `DETACHED_PROCESS` (in my tests, I specified both).

Resolving patch:
diff --git a/src/virtualenv/seed/wheels/periodic_update.py b/src/virtualenv/seed/wheels/periodic_update.py
--- a/src/virtualenv/seed/wheels/periodic_update.py
+++ b/src/virtualenv/seed/wheels/periodic_update.py
@@ -22,7 +22,7 @@
 from virtualenv.app_data import AppDataDiskFolder
 from virtualenv.info import PY2
 from virtualenv.util.path import Path
-from virtualenv.util.subprocess import DETACHED_PROCESS, Popen
+from virtualenv.util.subprocess import CREATE_NO_WINDOW, Popen
 
 from ..wheels.embed import BUNDLE_SUPPORT
 from ..wheels.util import Wheel
@@ -186,7 +186,7 @@ def trigger_update(distribution, for_py_version, wheel, search_dirs, app_data, p
     pipe = None if debug else subprocess.PIPE
     kwargs = {"stdout": pipe, "stderr": pipe}
     if not debug and sys.platform == "win32":
-        kwargs["creationflags"] = DETACHED_PROCESS
+        kwargs["creationflags"] = CREATE_NO_WINDOW
     process = Popen(cmd, **kwargs)
     logging.info(
         "triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",
diff --git a/src/virtualenv/util/subprocess/__init__.py b/src/virtualenv/util/subprocess/__init__.py
--- a/src/virtualenv/util/subprocess/__init__.py
+++ b/src/virtualenv/util/subprocess/__init__.py
@@ -13,7 +13,7 @@
     Popen = subprocess.Popen
 
 
-DETACHED_PROCESS = 0x00000008
+CREATE_NO_WINDOW = 0x80000000
 
 
 def run_cmd(cmd):
@@ -32,5 +32,5 @@ def run_cmd(cmd):
     "subprocess",
     "Popen",
     "run_cmd",
-    "DETACHED_PROCESS",
+    "CREATE_NO_WINDOW",
 )


Test patch:
diff --git a/tests/unit/seed/wheels/test_periodic_update.py b/tests/unit/seed/wheels/test_periodic_update.py
--- a/tests/unit/seed/wheels/test_periodic_update.py
+++ b/tests/unit/seed/wheels/test_periodic_update.py
@@ -29,7 +29,7 @@
     trigger_update,
 )
 from virtualenv.util.path import Path
-from virtualenv.util.subprocess import DETACHED_PROCESS
+from virtualenv.util.subprocess import CREATE_NO_WINDOW
 
 
 @pytest.fixture(autouse=True)
@@ -224,7 +224,7 @@ def test_trigger_update_no_debug(for_py_version, session_app_data, tmp_path, moc
     assert args == ([sys.executable, "-c", cmd],)
     expected = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
     if sys.platform == "win32":
-        expected["creationflags"] = DETACHED_PROCESS
+        expected["creationflags"] = CREATE_NO_WINDOW
     assert kwargs == expected
     assert process.communicate.call_count == 0