[Libguestfs] [PATCH v2v] v2v: windows: Fix schtasks /SD parameter.

Richard W.M. Jones rjones at redhat.com
Mon Nov 30 09:13:31 UTC 2020


Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1895323
---
 v2v/convert_windows.ml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index 3e41262d80..06d0d8cd3d 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -428,11 +428,12 @@ popd
  and configure_qemu_ga files =
    List.iter (
      fun msi_path ->
+       (* Windows is a trashfire. https://stackoverflow.com/a/18730884 *)
        let fb_script = sprintf "\
 echo Removing any previously scheduled qemu-ga installation
 schtasks.exe /Delete /TN Firstboot-qemu-ga /F
 echo Scheduling delayed installation of qemu-ga from %s
-powershell.exe -command \"$d = (get-date).AddSeconds(120); schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString('MM/dd/yyyy') /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\"
+powershell.exe -command \"$d = (get-date).AddSeconds(120); $FormatHack = ($([System.Globalization.DateTimeFormatInfo]::CurrentInfo.ShortDatePattern) -replace 'M+/', 'MM/') -replace 'd+/', 'dd/'; schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString($FormatHack) /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\"
       "
       msi_path msi_path msi_path in
       Firstboot.add_firstboot_script g inspect.i_root
-- 
2.28.0.rc2




More information about the Libguestfs mailing list