Sebastian
Sebastian

Reputation: 514

Kill explorer.exe with windows title

I'm new with programing and my question is now, how i can close some specific explorer.exe windows. My Problem is, i have a program that call some windows:

Option Explicit

Dim shell, expl1, expl2, expl3, Terminate

Dim uprgExplorer

  set shell = WScript.CreateObject("WScript.Shell")
  set expl1 = shell.exec("C:\WINDOWS\explorer.exe c:\Documents and Settings")
  set expl2 = shell.exec("C:\WINDOWS\explorer.exe C:\WINDOWS\system32\CCM\Cache")
  set expl3 = shell.exec("C:\WINDOWS\explorer.exe c:\SCRIPTS\LOG")

Now i will kill only this 3 windows NOT the explorer.exe.

Can some one help me?

Greetings,

matthias

Upvotes: 3

Views: 3195

Answers (1)

Dirk Vollmar
Dirk Vollmar

Reputation: 176229

You could use the SendKeys function to close the Explorer windows:

set shell = WScript.CreateObject("WScript.Shell")

set expl1 = shell.exec("C:\WINDOWS\explorer.exe c:\tmp")

MsgBox "Explorer started."

success = shell.appactivate("c:\tmp")
if success then shell.sendkeys "%{F4}" 

You might also want to have a look at AutoHotkey, which allows you to record macros and manipulate windows.

Upvotes: 1

Related Questions