tags:

views:

147

answers:

2

Hello,

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

A: 

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.

0xA3
thank you very mutch :-) now its perfect.
matthias
A: 

hey thank you...this is a good way...problem is...i will close the window not after a time, i will make an msgbox and when i click the OK than it will be closed...

is that possible?

sry for my bad english :-)

matthias
See my updated answer. By the way, welcome to StackOverflow. This site works a little different than usual forums. Replies to a specific answer should be posted as a comment, not as a separate answer (as they are not really an answer). If you like an answer and it was useful, vote it up, if you didn't like it or it is not helpful, you may vote it down. If an answer actually solved your problem, you should mark it as accepted. This way your post will be the most useful to others.
0xA3