(args: ValidatedSetAutoStartArgs, tempFilePath?: string)
| 666 | } |
| 667 | |
| 668 | function buildSetAutoStartScript(args: ValidatedSetAutoStartArgs, tempFilePath?: string): string { |
| 669 | const runtimeSetup = tempFilePath |
| 670 | ? `$payload = Get-Content -LiteralPath ${powerShellString(tempFilePath)} -Raw | ConvertFrom-Json |
| 671 | $enabled = [bool]$payload.enabled |
| 672 | $taskName = [string]$payload.taskName |
| 673 | $exePath = [string]$payload.exePath` |
| 674 | : `$enabled = ${args.enabled ? '$true' : '$false'} |
| 675 | $taskName = ${powerShellString(args.taskName)} |
| 676 | $exePath = ${powerShellString(args.exePath)}` |
| 677 | return `${buildPowerShellPreamble()} |
| 678 | ${runtimeSetup} |
| 679 | if ($enabled) { |
| 680 | & schtasks.exe /create /tn $taskName /tr ('"' + $exePath + '"') /sc onlogon /rl highest /f | Out-Null |
| 681 | if ($LASTEXITCODE -ne 0) { |
| 682 | throw "schtasks.exe /create failed with exit code $LASTEXITCODE" |
| 683 | } |
| 684 | } |
| 685 | else { |
| 686 | & schtasks.exe /delete /tn $taskName /f | Out-Null |
| 687 | if ($LASTEXITCODE -ne 0) { |
| 688 | throw "schtasks.exe /delete failed with exit code $LASTEXITCODE" |
| 689 | } |
| 690 | }` |
| 691 | } |
| 692 | |
| 693 | function buildSslAddTrustedCertScript(args: ValidatedSslAddTrustedCertArgs): string { |
| 694 | return `${buildPowerShellPreamble()} |
no test coverage detected