MCPcopy Create free account
hub / github.com/xpf0000/FlyEnv / buildSetSystemEnvScript

Function buildSetSystemEnvScript

src/shared/WindowsHelperFallback.ts:644–666  ·  view source on GitHub ↗
(args: ValidatedSetSystemEnvArgs, tempFilePath?: string)

Source from the content-addressed store, hash-verified

642}
643
644function 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}
656else {
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
661Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $key -Value $value`
662 return `${buildPowerShellPreamble()}
663${runtimeSetup}
664${writeValue}
665${buildNotifyEnvironmentChangedScript()}`
666}
667
668function buildSetAutoStartScript(args: ValidatedSetAutoStartArgs, tempFilePath?: string): string {
669 const runtimeSetup = tempFilePath

Callers 1

Calls 3

powerShellStringFunction · 0.85
buildPowerShellPreambleFunction · 0.85

Tested by

no test coverage detected