Skip to content

refreshenv.cmd uses hard-coded temp files #1986

Open
@jvuori

Description

@jvuori

What You Are Seeing?

When running refreshenv at the same time under multiple command prompt windows it tries to write _envset.tmp and _env.cmd but ends up in a race condition situation as the files are locked by other process. This is not an issue when running refreshenv manually but when automating things and optimizing the automation by parallelism.

What is Expected?

The temp files should be written with random file names.

How Did You Get This To Happen? (Steps to Reproduce)

Write a script which launches multiple command prompts and runs refreshenv on each.

@echo off
start cmd /k refreshenv
start cmd /k refreshenv

Output Log

Refreshing environment variables from registry for cmd.exe. Please wait...The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
C:\Users\Administrator\AppData\Local\Temp\_envset.tmp
C:\Users\Administrator\AppData\Local\Temp\_env.cmd
Finished..

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions