mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +00:00
Remove Dotnet.ps1 post-generation script (#4585)
This commit is contained in:
committed by
GitHub
parent
120fc45b76
commit
acc3d7cc0d
@@ -1,3 +1,38 @@
|
||||
function Connect-Hive {
|
||||
param(
|
||||
[string]$FileName = "C:\Users\Default\NTUSER.DAT",
|
||||
[string]$SubKey = "HKLM\DEFAULT"
|
||||
)
|
||||
|
||||
Write-Host "Loading the file $FileName to the Key $SubKey"
|
||||
if (Test-Path $SubKey.Replace("\",":")) {
|
||||
return
|
||||
}
|
||||
|
||||
$result = reg load $SubKey $FileName *>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Failed to load hive: $result"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Disconnect-Hive {
|
||||
param(
|
||||
[string]$SubKey = "HKLM\DEFAULT"
|
||||
)
|
||||
|
||||
Write-Host "Unloading the hive $SubKey"
|
||||
if (-not (Test-Path $SubKey.Replace("\",":"))) {
|
||||
return
|
||||
}
|
||||
|
||||
$result = reg unload $SubKey *>&1
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Failed to unload hive: $result"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Get-SystemVariable {
|
||||
param(
|
||||
[string]$SystemVariable
|
||||
@@ -6,6 +41,19 @@ function Get-SystemVariable {
|
||||
[System.Environment]::GetEnvironmentVariable($SystemVariable, "Machine")
|
||||
}
|
||||
|
||||
function Get-DefaultVariable {
|
||||
param(
|
||||
[string]$DefaultVariable,
|
||||
[string]$Name = "DEFAULT\Environment",
|
||||
[bool]$Writable = $false
|
||||
)
|
||||
|
||||
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($Name, $Writable)
|
||||
$key.GetValue($DefaultVariable, "", "DoNotExpandEnvironmentNames")
|
||||
$key.Handle.Close()
|
||||
[System.GC]::Collect()
|
||||
}
|
||||
|
||||
function Set-SystemVariable {
|
||||
param(
|
||||
[string]$SystemVariable,
|
||||
@@ -16,10 +64,30 @@ function Set-SystemVariable {
|
||||
Get-SystemVariable $SystemVariable
|
||||
}
|
||||
|
||||
function Set-DefaultVariable {
|
||||
param(
|
||||
[string]$DefaultVariable,
|
||||
[string]$Value,
|
||||
[string]$Name = "DEFAULT\Environment",
|
||||
[string]$Kind = "ExpandString",
|
||||
[bool]$Writable = $true
|
||||
)
|
||||
|
||||
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($Name, $Writable)
|
||||
$key.SetValue($DefaultVariable, $Value, $Kind)
|
||||
Get-DefaultVariable $DefaultVariable
|
||||
$key.Handle.Close()
|
||||
[System.GC]::Collect()
|
||||
}
|
||||
|
||||
function Get-MachinePath {
|
||||
Get-SystemVariable PATH
|
||||
}
|
||||
|
||||
function Get-DefaultPath {
|
||||
Get-DefaultVariable Path
|
||||
}
|
||||
|
||||
function Set-MachinePath {
|
||||
param(
|
||||
[string]$NewPath
|
||||
@@ -28,6 +96,14 @@ function Set-MachinePath {
|
||||
Set-SystemVariable PATH $NewPath
|
||||
}
|
||||
|
||||
function Set-DefaultPath {
|
||||
param(
|
||||
[string]$NewPath
|
||||
)
|
||||
|
||||
Set-DefaultVariable PATH $NewPath
|
||||
}
|
||||
|
||||
function Test-MachinePath {
|
||||
param(
|
||||
[string]$PathItem
|
||||
@@ -46,3 +122,15 @@ function Add-MachinePathItem {
|
||||
$newPath = $PathItem + ';' + $currentPath
|
||||
Set-MachinePath -NewPath $newPath
|
||||
}
|
||||
|
||||
function Add-DefaultPathItem {
|
||||
param(
|
||||
[string]$PathItem
|
||||
)
|
||||
|
||||
Connect-Hive
|
||||
$currentPath = Get-DefaultPath
|
||||
$newPath = $PathItem + ';' + $currentPath
|
||||
Set-DefaultPath -NewPath $newPath
|
||||
Disconnect-Hive
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user