(options: {
readonly command: string;
readonly arguments?: string;
readonly userId: string;
readonly boot?: boolean;
})
| 650 | * such dependency and a non-admin install succeeds. |
| 651 | */ |
| 652 | export const generateWindowsTaskXml = (options: { |
| 653 | readonly command: string; |
| 654 | readonly arguments?: string; |
| 655 | readonly userId: string; |
| 656 | readonly boot?: boolean; |
| 657 | }): string => { |
| 658 | const user = xmlEscape(options.userId); |
| 659 | const trigger = options.boot |
| 660 | ? "<BootTrigger><Enabled>true</Enabled></BootTrigger>" |
| 661 | : `<LogonTrigger><Enabled>true</Enabled><UserId>${user}</UserId></LogonTrigger>`; |
| 662 | const logonType = options.boot ? "S4U" : "InteractiveToken"; |
| 663 | const runLevel = options.boot ? "HighestAvailable" : "LeastPrivilege"; |
| 664 | const action = options.arguments |
| 665 | ? `<Exec><Command>${xmlEscape(options.command)}</Command><Arguments>${xmlEscape(options.arguments)}</Arguments></Exec>` |
| 666 | : `<Exec><Command>${xmlEscape(options.command)}</Command></Exec>`; |
| 667 | return [ |
| 668 | '<?xml version="1.0" encoding="UTF-16"?>', |
| 669 | '<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">', |
| 670 | " <RegistrationInfo><Description>Executor supervised daemon</Description></RegistrationInfo>", |
| 671 | ` <Triggers>${trigger}</Triggers>`, |
| 672 | " <Principals>", |
| 673 | ` <Principal id="Author"><UserId>${user}</UserId><LogonType>${logonType}</LogonType><RunLevel>${runLevel}</RunLevel></Principal>`, |
| 674 | " </Principals>", |
| 675 | " <Settings>", |
| 676 | " <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>", |
| 677 | " <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>", |
| 678 | " <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>", |
| 679 | " <StartWhenAvailable>true</StartWhenAvailable>", |
| 680 | " <RestartOnFailure><Interval>PT1M</Interval><Count>3</Count></RestartOnFailure>", |
| 681 | " <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>", |
| 682 | " <Enabled>true</Enabled>", |
| 683 | " </Settings>", |
| 684 | ' <Actions Context="Author">', |
| 685 | ` ${action}`, |
| 686 | " </Actions>", |
| 687 | "</Task>", |
| 688 | "", |
| 689 | ].join("\r\n"); |
| 690 | }; |
| 691 | |
| 692 | /** |
| 693 | * A tiny VBScript shim the task runs via `wscript.exe`. The default (logon) task |
no test coverage detected