quickly close all word and excel
- by dyenatha
Suppose I open 10 Word files and 10 Excel files and make no changes, how do I quickly taskkill all at once?
Because I must repeat several attempts to replicate race, I'm hoping for a command-line solution. I'm willing to try PowerShell and cygwin (1.5) if necessary.
The OS is Windows XP SP3 with current patches (still IE7).
I tried "taskkill /pid 1 /pid 2 /t" where 1 is PID of EXCEL.EXE and 2 is PID of WINWORD.EXE, but it closed only 1 window of each program.
I'm trying to replicate a race where an add-in for Microsoft Office 2007 fails to exclusive-lock one of its own files, which caused the 2nd Office program to stop exiting with a warning:
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)