Windows PEでバックアップ・リストア(7)

次にRestoreボタンを押したときの処理です。

$RestoreBtn.Add_Click({

    $choose = Select-Drive
    if ($choose) {
        
        if ($choose -is [array]) { $choose = $choose[-1] }
        $chooseDrv=$choose
        

        #$PathBox.Text = Join-Path $folder "backup.ffu"
        Log "Selected Drive: $chooseDrv"
    }
    $path = $PathBox.Text
    if (-not $path) { Log "No path specified."; return }

    if (-not (Test-Path $path)) {
        Log "File not found: $path"
        return
    }

    Log "Starting restore..."
    $Progress.Value = 10

    $args = "/apply-ffu /imagefile:`"$path`" /applydrive:\\.\PhysicalDrive$chooseDrv"
    Log $args
    Start-Process dism -ArgumentList $args -Wait -NoNewWindow

    $Progress.Value = 100
    Log "Restore completed."
})

Select-Drive関数でリストアするドライブを選択、その後Path:のボックスに入っている文字列を取得し、そのボリューム内にある"backup.ffu"ファイルを取得し、そのファイルでリストアする処理です。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です