Windows Server Summit 2024
Mar 26 2024 08:00 AM - Mar 28 2024 04:30 PM (PDT)
Microsoft Tech Community

Error when creating task using command prompt in Windows 2019 docker container

Copper Contributor

My host is Windows 2019 standard. It contains docker image which is also based on Windows 2019 standard core (no GUI). This is the image I am using: 


When I run following command on host then it works fine. But running same command in Docker container results in error.



schtasks /create /sc minute /mo 1 /tn StudentManagementSystem /tr C:\StudentManagementSystemConsole\StudentManagementSystemConsole.exe



The task XML contains a value which is incorrectly formatted or out of range


Using following PowerShell script in Docker container also results in exact same error.


$action = New-ScheduledTaskAction -Execute "node" -Argument "C:\StudentManagementSystemConsole\StudentManagementSystemConsole.exe"
$now = Get-Date
$interval = New-TimeSpan -Seconds 60
$forever = [System.TimeSpan]::MaxValue
$trigger = New-ScheduledTaskTrigger -Once -At $now -RepetitionInterval $interval
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask -TaskName ‘Student Management System’ -InputObject $task

How to fix this issue?

0 Replies