(args: ValidatedSetSystemEnvArgs, tempFilePath?: string)
| 642 | } |
| 643 | |
| 644 | function buildSetSystemEnvScript(args: ValidatedSetSystemEnvArgs, tempFilePath?: string): string { |
| 645 | const runtimeSetup = tempFilePath |
| 646 | ? `$payload = Get-Content -LiteralPath ${powerShellString(tempFilePath)} -Raw | ConvertFrom-Json |
| 647 | $key = [string]$payload.key |
| 648 | $value = [string]$payload.value` |
| 649 | : `$key = ${powerShellString(args.key)} |
| 650 | $value = ${powerShellString(args.value)}` |
| 651 | const writeValue = |
| 652 | tempFilePath || args.value.includes('%') |
| 653 | ? `if ($value.Contains('%')) { |
| 654 | New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value -PropertyType ExpandString -Force | Out-Null |
| 655 | } |
| 656 | else { |
| 657 | New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value -PropertyType String -Force | Out-Null |
| 658 | Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value |
| 659 | }` |
| 660 | : `New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value -PropertyType String -Force | Out-Null |
| 661 | Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value` |
| 662 | return `${buildPowerShellPreamble()} |
| 663 | ${runtimeSetup} |
| 664 | ${writeValue} |
| 665 | ${buildNotifyEnvironmentChangedScript()}` |
| 666 | } |
| 667 | |
| 668 | function buildSetAutoStartScript(args: ValidatedSetAutoStartArgs, tempFilePath?: string): string { |
| 669 | const runtimeSetup = tempFilePath |
no test coverage detected