cschneegans / unattend-generator

.NET Core library to create highly customized autounattend.xml files
https://schneegans.de/windows/unattend-generator/
MIT License
634 stars 55 forks source link

Enabling VirtIO installation is broken #18

Open lmb opened 4 months ago

lmb commented 4 months ago

The generator currently outputs the following XML when enabling virtio installation:

<RunSynchronousCommand wcm:action="add">
  <Order>24</Order>
  <Path>powershell.exe -NoProfile -Command "Get-Content -LiteralPath '%TEMP%\VirtIoGuestTools.ps1' -Raw | Invoke-Expression;"</Path>

<File path="%TEMP%\VirtIoGuestTools.ps1">
  <!-- etc. -->
</File>

On Windows startup a cmd.exe window pops open and asks for an Option "Path" (or similar, this is from the top of my head). The script itself is not run. I believe this is due to a problem with the extraction script, which doesn't properly handle the %TEMP% expansion. Manually rewriting the path to C:\Windows\Setup\Scripts\VirtIoGuestTools.ps1 fixes the problem.

Thanks for this great project!

cschneegans commented 4 months ago

Sorry, cannot reproduce. The extraction script uses the [System.Environment]::ExpandEnvironmentVariables method to expand environment variables. I don't have a Proxmox environment available right now, but using your exact autounattend.xml file on a VMware Windows 10 machine still executes the VirtIoGuestTools.ps1 script, which outputs a single line to the %TEMP%\VirtIoGuestTools.log file, as expected:

VirtIO Guest Tools image (virtio-win-*.iso) is not attached to this VM.

Note that the logfile's absolute path is C:\Windows\Temp\VirtIoGuestTools.log, not C:\Users\Admin\AppData\Local\Temp\VirtIoGuestTools.log, and that you need administrative permissions to read it. Does the logfile file exist on your machine?

I admit that using the %TEMP% variable might unnecessarily complicate things while having little benefit, so I will consider replacing it with a constant C:\Windows\Temp or C:\Windows\Setup\Scripts path.