Dirty Environment Found with ASUS bios updates.

lupinlicious 136 Reputation points
2023-05-20T06:17:00.21+00:00

Hello,

I'm trying to update ASUS BIOS, and during the update, the tool "afuwinx64.exe" asks, "System is going to shut down, are you ready? (Y/N)". If I press "Y" the update works but breaks task sequences. If I press "N," means no update, and MDT continue with the task sequence.

Can I add something before the BIOS update so MDT can continue from where it left off?

My task sequence is under State Restore "Custom Tasks," I also tried to add the following command lines before the BIOS update:

cmd /c reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v FilterAdministratorToken /t REG_DWORD /d 0 /f

cscript.exe "%SCRIPTROOT%\LTIApply.wsf" /PE /STAGE

cscript.exe "%SCRIPTROOT%\LTIApply.wsf" /PE /BCD

And the BIOS update itself:

New-PSDrive -Name "A" -Root $scriptDirectory -Persist -PSProvider "FileSystem"
 
$cmdPath = "C:\Windows\System32\cmd.exe"
$command = "/c cd C:\ProgramData\bios & echo Y | afuwinx64.exe Q170M-C-SI-4212.CAP /P /B /N /K /CAPSULE"
 
       
$baseboardModel = (Get-WmiObject -Class Win32_BaseBoard | Select-Object -ExpandProperty Product)

$ScriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
$FilesPath = Join-Path -Path $ScriptDirectory -ChildPath "Files"
$ModelPath = Join-Path -Path $FilesPath -ChildPath $baseboardModel

if ($baseboardModel -eq $baseboardModel -and (Test-Path $ModelPath)) {
    # Create destination folder if it doesn't exist
    $destinationFolder = "C:\ProgramData\bios"
    if (!(Test-Path $destinationFolder)) {
        New-Item -Path $destinationFolder -ItemType Directory | Out-Null
    }

    # Copy AFUWINx64.EXE, amifldrv64.sys, and Q170M-C-SI-4212 to the destination folder
    $filesToCopy = @("AFUWINx64.EXE", "amifldrv64.sys", "Q170M-C-SI-4212.CAP")
    foreach ($file in $filesToCopy) {
        $sourcePath = Join-Path -Path $ModelPath -ChildPath $file
        $destinationPath = Join-Path -Path $destinationFolder -ChildPath $file
        Copy-Item -Path $sourcePath -Destination $destinationPath -Force -Verbose
    }

    # Get Bios File Name (Uses the Bios ROM file in the model folder)
    $BiosFileName = Get-ChildItem -Path $ModelPath -Filter *.CAP -Recurse -Verbose | Select-Object -ExpandProperty Name

    # Get Bios File Name (No Extension, used to create Log File)
    $BiosLogFileName = (Get-ChildItem -Path $ModelPath -Filter *.CAP -Verbose | Select-Object -ExpandProperty BaseName) + ".log"

    # Set Command Arguments for BIOS Update
    $exeName = Join-Path -Path $destinationFolder -ChildPath "AFUWINx64.EXE"
    $ROMName = Get-ChildItem -Path $destinationFolder -Include "*.CAP" -Name
    $logFilePath = Join-Path -Path $destinationFolder -ChildPath "Files\$deviceID.log"
    $parameters = "/P /B /N /K /CAPSULE"

    Set-Location -Path $destinationFolder
    #Execute-Process -Path $exeName -Parameters $ROMName, $parameters
    Start-Process -FilePath $cmdPath -ArgumentList $command -Wait -NoNewWindow 
    

    Write-Host "Performing BIOS update for $baseboardModel."
}
else {
    Write-Host "No BIOS update required for the detected baseboard model: $baseboardModel."
}

I'm also struggling with "Echo Y", I want it to say "Yes" in the prompt automatically.

Thaaaanks!

Windows for business | Windows Client for IT Pros | Devices and deployment | Set up, install, or upgrade
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenLiu-MSFT 49,316 Reputation points Microsoft External Staff
    2023-05-22T07:24:20.7366667+00:00

    Hi, @lupinlicious

    Thank you for posting in Microsoft Q&A forum.

    Can the afuwinx64.exe run silently? How about add a "Restart computer" step manually?

    https://www.joseespitia.com/2017/01/30/automate-your-bios-update-in-mdt/


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.