Skip to content

Commit

Permalink
convert/convert_windows.ml: Handle date formats with dots instead of /
Browse files Browse the repository at this point in the history
If the ShortDatePattern is yy.M.d (as can happen for US locale) we may
not always reformat the date for schtasks.exe correctly.  For
explanation and testing see:

https://bugzilla.redhat.com/show_bug.cgi?id=1895323#c46 (- #c50)

Thanks: Xiaodai Wang for suggesting the fix and testing it
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1895323
  • Loading branch information
rwmjones committed Nov 12, 2021
1 parent 7a93451 commit d9dc6c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions convert/convert_windows.ml
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,15 @@ popd
and configure_qemu_ga files =
List.iter (
fun msi_path ->
(* Windows is a trashfire. https://stackoverflow.com/a/18730884 *)
(* Windows is a trashfire.
* https://stackoverflow.com/a/18730884
* https://bugzilla.redhat.com/show_bug.cgi?id=1895323
*)
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); $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\\\"\"
powershell.exe -command \"$d = (get-date).AddSeconds(120); $FormatHack = (($([System.Globalization.DateTimeFormatInfo]::CurrentInfo.ShortDatePattern) -replace 'y+', 'yyyy') -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
Expand Down

0 comments on commit d9dc6c4

Please sign in to comment.