You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何PowerShell脚本仅启动AOMEI Backupper却不执行后续备份步骤?

问题排查与修复方案

1. 修正AOMEI Backupper命令行参数格式

AOMEI Backupper的命令行参数默认使用**斜杠/**作为前缀,而非脚本中的短横线-。错误的参数格式会导致程序仅启动GUI界面,无法执行备份命令。修正后的备份命令如下:

& $abtExecutable /backup /system /dest:"$backupDestination" /password:"$password" /compression:$compression

如果需要完全静默执行(不弹出任何界面),可以追加/silent参数:

& $abtExecutable /backup /system /dest:"$backupDestination" /password:"$password" /compression:$compression /silent

2. 完善旧备份删除逻辑(避免目录不存在导致脚本中断)

若$backupDestination目录不存在,Get-ChildItem会抛出错误,可能中断后续脚本执行。可以先判断目录状态,再执行删除或创建操作:

# Check if there is already a system image backup from 30 days ago
$thirtyDaysAgo = (Get-Date).AddDays(-30)
if (Test-Path $backupDestination) {
    $oldBackup = Get-ChildItem $backupDestination -Recurse | Where-Object { $_.LastWriteTime -lt $thirtyDaysAgo }
    # If there is an old backup, delete it
    if ($oldBackup) {
        Remove-Item -Path $oldBackup.FullName -Force -Recurse
    }
} else {
    # Create destination directory if it doesn't exist
    New-Item -Path $backupDestination -ItemType Directory -Force | Out-Null
}

这里补充了:

  • Test-Path检查备份目录是否存在
  • 目录不存在时自动创建
  • Get-ChildItem添加-Recurse遍历备份生成的子目录
  • Remove-Item添加-Recurse确保删除目录及内部所有内容

3. 以管理员权限运行脚本

AOMEI Backupper创建系统镜像需要管理员权限,若脚本未以管理员身份运行,可能会静默失败或仅启动GUI。右键PowerShell选择以管理员身份运行后再执行脚本。

完整修复后的脚本

# Set the path to the AOMEI Backupper Technician executable
$abtExecutable = "C:\Program Files (x86)\AOMEI Backupper Technician\Backupper.exe"

# Set the destination for the system image backup
$backupDestination = "C:\Backups\System Image"

# Set the password for the backup
$password = "12121212121212121212"

# Set the compression level to 'high'
$compression = "high"

# Check backup destination and clean old backups
$thirtyDaysAgo = (Get-Date).AddDays(-30)
if (Test-Path $backupDestination) {
    $oldBackup = Get-ChildItem $backupDestination -Recurse | Where-Object { $_.LastWriteTime -lt $thirtyDaysAgo }
    if ($oldBackup) {
        Remove-Item -Path $oldBackup.FullName -Force -Recurse
        Write-Host "Deleted old backup(s): $($oldBackup.FullName)"
    } else {
        Write-Host "No old backups found to delete."
    }
} else {
    New-Item -Path $backupDestination -ItemType Directory -Force | Out-Null
    Write-Host "Created backup destination directory: $backupDestination"
}

# Create the full system image backup with silent mode
Write-Host "Starting system image backup..."
& $abtExecutable /backup /system /dest:"$backupDestination" /password:"$password" /compression:$compression /silent

# Check if backup completed successfully
if ($LASTEXITCODE -eq 0) {
    Write-Host "System image backup completed successfully."
} else {
    Write-Host "Backup failed with exit code: $LASTEXITCODE"
}

内容的提问来源于stack exchange,提问作者ProprietaryCloudGaming

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 12:01:08