Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)
share|improve this question

1 Answer 1

"taskkill /F /IM excel.exe" kills all open Excel files on my Windows XP machine.

share|improve this answer
    
I think that kill is too efficient to engender the race: I had tried that, and it kills without closing the open document files: When I reopen Word, each opened document becomes a "recoverable" document. –  user34312 Apr 15 '10 at 18:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.