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

Windows 10批处理中如何单独关闭Acrobat Reader DC的指定文档?

如何在Windows 10中单独关闭Acrobat Reader DC的指定文档

因为Acrobat Reader DC默认采用单进程多窗口架构,直接用taskkill命令会关闭整个程序(所有文档),所以要单独关闭指定文档,我们需要通过窗口消息来定位并关闭目标文档窗口。下面提供两种实用方案:

方案1:使用VBScript(兼容所有Windows 10版本)

这种方法通过脚本遍历Acrobat的窗口,匹配目标文档名后发送关闭指令,操作简单且无需额外配置。

步骤1:创建VBS脚本文件

新建一个文本文件,命名为CloseAcrobatDoc.vbs,粘贴以下代码:

Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
strTargetDoc = WScript.Arguments(0)

' 遍历所有打开的窗口,筛选Acrobat Reader的目标文档
For Each objWindow In objWindows
    ' 验证是Acrobat进程且窗口包含目标文档名
    If InStr(objWindow.FullName, "AcroRd32.exe") > 0 And InStr(objWindow.LocationName, strTargetDoc) > 0 Then
        objWindow.Quit()
        WScript.Echo "已成功关闭文档: " & strTargetDoc
        WScript.Quit(0)
    End If
Next

WScript.Echo "未找到指定文档: " & strTargetDoc
WScript.Quit(1)

步骤2:在批处理中调用脚本

要关闭A.pdf,只需在批处理里添加以下命令:

cscript //nologo CloseAcrobatDoc.vbs "A.pdf"

说明:

  • 脚本中的LocationName对应Acrobat窗口显示的文档文件名(不受意大利语版本影响,始终是文件名本身)。
  • 如果存在重名文档,脚本会关闭第一个匹配到的窗口,建议确保目标文档文件名唯一。

方案2:使用PowerShell(更灵活的进阶方案)

如果你的系统允许使用PowerShell,可以用以下命令直接在批处理中执行,无需单独创建脚本:

powershell -ExecutionPolicy Bypass -Command "$docName = 'A.pdf'; $acroWindows = Get-Process AcroRd32 | Select-Object -ExpandProperty MainWindowTitle | Where-Object { $_ -like "*$docName*" }; foreach ($window in $acroWindows) { $hwnd = (Get-Process AcroRd32 | Where-Object { $_.MainWindowTitle -eq $window }).MainWindowHandle; Add-Type '@`nusing System;`nusing System.Runtime.InteropServices;`npublic class Win32 {`n    [DllImport(""user32.dll"")]`n    public static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);`n    public const uint WM_CLOSE = 0x0010;`n}'@; [Win32]::PostMessage($hwnd, [Win32]::WM_CLOSE, 0, 0) }"

说明:

  • 该命令通过调用Windows API发送WM_CLOSE消息关闭指定窗口,不会影响其他文档。
  • 如果你的系统PowerShell执行策略受限,-ExecutionPolicy Bypass参数已临时放宽策略。

关键注意点

  • 无论使用哪种方案,都要确保目标文档的文件名准确匹配(包括后缀.pdf)。
  • 意大利语版本的Acrobat Reader窗口标题不会影响脚本判断,因为我们是基于文件名和进程名筛选,而非程序的本地化标题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 08:49:37