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?

2
  • 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. Commented Jun 28, 2015 at 7:10
  • yes i think also there is a way to do it -but how? Commented Jun 28, 2015 at 8:43

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

2 Comments

it works-thanks Sergev. but if i want to uninstall nircmd-how do i do it?
In FAQ (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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.