Task Does not Create on French OS Computer to English Computer
Describe the bug Using this library to create a task from powershell or C# on a French OS results in the following error. This error message is generated from powershell and is slightly different in C#:
Exception lors de l'appel de « RegisterTaskDefinition » avec « 2 » argument(s) : « (16,8):UserId: »
Au caractère Ligne:1 : 1
English translation:
Exception when calling 'RegisterTaskDefinition' with '2' argument(s): '(16,8):UserId:'
To the character Line:1: 1
To Reproduce Steps to reproduce the behavior in Powershell:
add-type -Path "Microsoft.Win32.TaskScheduler.dll"
$ts = [Microsoft.Win32.TaskScheduler.TaskService]::new("\\MyPC")
$td = $ts.NewTask()
$td.Principal.UserId = "SYSTEM"
$td.Principal
$td.Principal.LogonType = "ServiceAccount"
$trigger = [Microsoft.Win32.TaskScheduler.TimeTrigger]::new()
$td.Triggers.Add($trigger)
$trigger.StartBoundary = get-date 2024/01/24
$act = [Microsoft.Win32.TaskScheduler.ExecAction]::new()
$act.Path = "C:\windows\system32\CMD.exe"
$td.Actions.Add($act)
$ts.RootFolder.RegisterTaskDefinition("Test_Task", $td)
Expected behavior I expect "Test_Task" to be created on MyPC. but get the error instead.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- Host Windows version (the one running the code): Windows 11 Version 23H2 Build 22631.2715
- OS culture version As reported by powershell "Get-Culture":
Parent : fr
LCID : 3084
KeyboardLayoutId : 3084
Name : fr-CA
IetfLanguageTag : fr-CA
DisplayName : Français (Canada)
NativeName : français (Canada)
EnglishName : French (Canada)
TwoLetterISOLanguageName : fr
ThreeLetterISOLanguageName : fra
ThreeLetterWindowsLanguageName : FRC
CompareInfo : CompareInfo - fr-CA
TextInfo : TextInfo - fr-CA
- Library version: 2.10.1
- Remote Windows version (if applicable): Windows 11 Version 23H2 Build 22631.2715
- English US culture (1033, en-US)
Additional context Add any other context about the problem here.
Resolution or at least a workaround may come in the form of creating the task from the XML:
$ts.RootFolder.RegisterTask(taskName, $td.XmlText)
Doing further testing to confirm.
Please reopen if you need further help.