- try to get access into the tmp folder

This commit is contained in:
denihs
2024-10-21 17:00:04 -04:00
parent deef079f70
commit 4cf29a0e2a

View File

@@ -113,11 +113,21 @@ Function Add-NodeAndNpm {
if (!(Get-Command nvm -ErrorAction SilentlyContinue)) {
Write-Host "NVM is not installed. Installing NVM..." -ForegroundColor Magenta
# NVM for Windows installation
$nvmUrl = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.10/nvm-setup.exe"
$nvmInstaller = Join-Path $dirTemp "nvm-setup.exe"
# Create a new temporary folder with explicit permissions
$tempFolderName = "MeteorNVMInstall_" + [System.Guid]::NewGuid().ToString()
$tempFolder = Join-Path $env:TEMP $tempFolderName
try {
New-Item -ItemType Directory -Path $tempFolder | Out-Null
$acl = Get-Acl $tempFolder
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($env:USERNAME, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.SetAccessRule($accessRule)
Set-Acl $tempFolder $acl
# NVM for Windows installation
$nvmUrl = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.10/nvm-setup.exe"
$nvmInstaller = Join-Path $tempFolder "nvm-setup.exe"
# Download NVM installer
$webclient.DownloadFile($nvmUrl, $nvmInstaller)
@@ -146,6 +156,12 @@ Function Add-NodeAndNpm {
}
throw "NVM installation failed. Please install it manually and try again."
}
finally {
# Clean up the temporary folder
if (Test-Path $tempFolder) {
Remove-Item -Recurse -Force $tempFolder
}
}
}