0

I am using python 2.7 and i work with a lot of open windows7 folders and with other programs at the same time. I have tried working with this code (in works fine perfect):

import os

os.system('taskkill /im chrome.exe')
os.system('taskkill /im powerpnt.exe')
os.system('taskkill /im outlook.exe')
os.system('taskkill /im winword.exe')
os.system('taskkill /im excel.exe')

but i don't know how to close all the folders and files (windows 7) at the same time too. I have tried the following

how to close remote desktop window using python

How to Close a program using python?

How to close all windows

but didn't understand the way to do it with python. Also, i tried to search the name process in the Task Manager but i didn't know the name of it. enter image description here

Is it possible to do it without damaging the operating system of the computer?

Community
  • 1
  • 1
user4989939
  • 349
  • 1
  • 3
  • 14
  • The name of the process I think you're looking for is "Windows Explorer" or 'explorer.exe'. Typically all explorer windows run in one process, which is *the same process* that displays the desktop and taskbar. I'm not sure how you would go about killing all folder windows without also killing the desktop, but there may be a way. – Sam Jun 28 '15 at 07:10
  • yes i think also there is a way to do it -but how? – user4989939 Jun 28 '15 at 08:43

1 Answers1

1

You can use nircmd (You need install nircmd - http://www.nirsoft.net/utils/nircmd.html)

and subprocess module:

import subprocess
subprocess.call('nircmd.exe win close class "CabinetWClass"' , shell=True)
Sergey Nosov
  • 350
  • 3
  • 10
  • it works-thanks Sergev. but if i want to uninstall nircmd-how do i do it? – user4989939 Jun 28 '15 at 09:29
  • In FAQ (http://www.nirsoft.net/faq.html) -------------------------------------------------------------------------------------------------------- Q: I used the utilities of NirSoft, and I don't want them anymore. How do I uninstall them ? ------------------------ A: First, some utilities provide an installer with full uninstall support. If you downloaded a utility with installer, you should go to 'Add/Remove' software of Windows and unistall it. If you downloaded a utility in a ZIP file, you should simply delete the zip file, and the other files that you extracted from it. – Sergey Nosov Jun 28 '15 at 12:49