cloudbase / windows-imaging-tools

Tools to automate the creation of a Windows image for OpenStack, supporting KVM, Hyper-V, ESXi and more.
Apache License 2.0
686 stars 230 forks source link

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

Open al-indigo opened 8 months ago

al-indigo commented 8 months ago

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