Saved Bookmarks
| 1. |
Solve : Want .bat file to close all open folders.? |
|
Answer» Is there a way to close all open folders in windows? Microsoft.com says the shortcut "CTRL + ALT + SHIFT + F4" does just that. But I can't get it to work. how did you "open" the folders in the first place? describe.I'd use the explorer COMMAND. Below is an example. Code: [Select]EXPLORER "D:\Erik's Documents\Photographs"TRY this vbscript which will kill all explorer.exe processes, ONLY as a last resort. Code: [Select]Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'") For Each objProcess in colProcessList objProcess.Terminate() Next Thank you ghostdog. That works nicely, but... I wish for only folders to be closed. What if I know exactly which folders I have open? Depending on what I'm doing I'll always have the same 3-5 folders open. That script closes down my toolbars, which I do not like.Quote from: And 1 on September 12, 2007, 01:28:07 AM Thank you ghostdog. That works nicely, but...that's why i said use as last resort. there are ways to do it, albeit more complex. 1) using tools like handle.exe. List open processes, get the PIDs , use taskkill 2) using tools like vbscript, run the explorer within vbscript , get the PIDs of each opened explorer and store them somewhere. Then when you want to close them, execute another part of the script to close all of them... 3) others..... However, I am sure you can just close it manually, since its only 3-5 folders?The PID's change each time right? Also, is there a way to modify that VBS you have to not close down toolbars?Code: [Select]Option Explicit Dim shell,oWindows,j Set shell = CreateObject("Shell.Application") set oWindows = shell.windows for j = 0 to oWindows.count - 1 oWindows.item(j).quit next set shell = nothing set oWindows = nothing The above demonstratoin clears all open windows you have. That gives an error for two or more folders opened. It works PERFECTLY for only one folder. Exact same error every time: Code: [Select]Script: C:\Documents and Settings\Erik\Desktop\test.vbs Line: 6 Char: 4 Error: OBJECT required: 'item(...)' Code: 800A01A8 Source: Microsoft VBScript runtime error If I have 4 folders open it will close 2, then give error. If I have 9 folders open it will close 5, then give error. 12, 6.....18, 9 Using Win XP Pro SP2 |
|