Forum Discussion

FrankMartin1610's avatar
FrankMartin1610
Copper Contributor
Feb 01, 2024

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

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:

 

mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 

 

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

 

Command

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

 

Error

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?

No RepliesBe the first to reply

Resources