cloudbase / windows-imaging-tools

Tools to automate the creation of a Windows image for OpenStack, supporting KVM, Hyper-V, ESXi and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TMP/TEMP env variable breaks ini.psm1 with non-ASCII usernames

al-indigo opened this issue · comments

Images:
en-us_windows_server_2019_x64_dvd_f9475476 -- works fine
ru-ru_windows_server_2019_x64_dvd_e02b76ba -- breaks in ini.psm1 with the following error (see the screen)

  1. I have discovered the reason: PowerShell internally compiles this code. During this compilation, the .NET Framework may use TempFileCollection to create temporary files for the compilation process. That temp file is generated as a shortname and it seems that different parts of Windows do not understand these paths equally.
  2. I have found a workaround, but I do not know your code enough to propose a pull request for this and be sure that it will not break anything for other systems.

But my straightforward fix looks like inserting in Logon.ps1 code the following snippet after line 8 or in ini.psm1 in the beginning:

New-Item -Path $resourcesDir\Temp -ItemType Directory -Force | Out-Null
$ENV:TMP = "$resourcesDir\Temp"
$ENV:TEMP = "$resourcesDir\Temp"

Hope it helps and you will decide for yourselves how to fix it in the most correct way

psm-error