![快速关闭所有 Word 和 Excel 实例?](https://linux22.com/image/1236446/%E5%BF%AB%E9%80%9F%E5%85%B3%E9%97%AD%E6%89%80%E6%9C%89%20Word%20%E5%92%8C%20Excel%20%E5%AE%9E%E4%BE%8B%EF%BC%9F.png)
假设我打开了 10 个 Word 文件和 10 个 Excel 文件并且没有做任何更改,我该如何快速一次性终止所有任务?
因为我必须多次尝试复制比赛,所以我希望有一个命令行解决方案。如果有必要,我愿意尝试 PowerShell 和 cygwin (1.5)。
操作系统是带有当前补丁的 Windows XP SP3(仍然是 IE7)。
我尝试了“taskkill /pid 1 /pid 2 /t”,其中 1 是 EXCEL.EXE 的 PID,2 是 WINWORD.EXE 的 PID,但它只关闭了每个程序的 1 个窗口。
我正在尝试复制这样的竞争:Microsoft Office 2007 的一个插件无法独占锁定它自己的某个文件,这导致第二个 Office 程序停止退出并显示警告:
System.IO.IOException: The process cannot access the file 'C:\Documents and Settings\me\Application
Data\ExpensiveProduct\Add-InForMicrosoftOffice\4.2\egcred' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share,
Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions
options)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
at ExpensiveProduct.EG.DataAccess.Credentials.CredentialManager.SaveUserTable()
at ExpensiveProduct.OfficeAddin.OfficeAddinBase.Dispose(Boolean disposing)
at ExpensiveProduct.OfficeAddin.WordAddin.Dispose(Boolean disposing)
at ExpensiveProduct.OfficeAddin.OfficeAddinBase.OnHostShutdown()
at ExpensiveProduct.OfficeAddin.OfficeAddinBase.Unload(ext_DisconnectMode mode)
答案1
“taskkill /F /IM excel.exe” 会终止我的 Windows XP 机器上所有打开的 Excel 文件。