From e01d3d07a5c6eda0873463c6ccb6dd7a8d3005d5 Mon Sep 17 00:00:00 2001 From: WindowsAddict Date: Tue, 19 Nov 2024 02:46:50 +0530 Subject: [PATCH] Update CheckFile --- static/get.ps1 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/static/get.ps1 b/static/get.ps1 index 3e2847c..d04d39b 100644 --- a/static/get.ps1 +++ b/static/get.ps1 @@ -5,15 +5,6 @@ Write-Host "The current command (irm https://massgrave.dev/get | iex) will be re Write-Host -ForegroundColor Green "Use the new command (irm https://get.activated.win | iex) moving forward." write-host -function CheckFile { - if (-not (Test-Path -Path $FilePath)) { - Check3rdAV - Write-Host "Failed to create MAS file in temp folder, aborting!" - Write-Host "Help - https://massgrave.dev/troubleshoot" -ForegroundColor White -BackgroundColor Blue - throw - } -} - function Check3rdAV { $avList = Get-CimInstance -Namespace root\SecurityCenter2 -Class AntiVirusProduct | Where-Object { $_.displayName -notlike '*windows*' } | Select-Object -ExpandProperty displayName if ($avList) { @@ -67,10 +58,15 @@ $isAdmin = [bool]([Security.Principal.WindowsIdentity]::GetCurrent().Groups -mat $FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$rand.cmd" } else { "$env:USERPROFILE\AppData\Local\Temp\MAS_$rand.cmd" } Set-Content -Path $FilePath -Value "@::: $rand `r`n$response" -CheckFile $env:ComSpec = "$env:SystemRoot\system32\cmd.exe" Start-Process -FilePath $env:ComSpec -ArgumentList "/c """"$FilePath"" $args""" -Wait -CheckFile +if (-not (Test-Path -Path $FilePath)) { + Check3rdAV + Write-Host "Failed to create MAS file in temp folder, aborting!" + Write-Host "Help - https://massgrave.dev/troubleshoot" -ForegroundColor White -BackgroundColor Blue + return +} + $FilePaths = @("$env:SystemRoot\Temp\MAS*.cmd", "$env:USERPROFILE\AppData\Local\Temp\MAS*.cmd") foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }