Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task Does not Create on French OS Computer to English Computer #979

Closed
paulwetter opened this issue Nov 22, 2023 · 2 comments
Closed

Task Does not Create on French OS Computer to English Computer #979

paulwetter opened this issue Nov 22, 2023 · 2 comments

Comments

@paulwetter
Copy link

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.

@paulwetter paulwetter changed the title Task Does not Create on French OS Computer Task Does not Create on French OS Computer to English Computer Nov 22, 2023
@paulwetter
Copy link
Author

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.

@dahall
Copy link
Owner

dahall commented May 25, 2024

Please reopen if you need further help.

@dahall dahall closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants