'Author: Demon
'Website: http://demon.tw
'Date: 2011/7/11
Option Explicit
Dim shell, window, path
Set shell = CreateObject("Shell.Application")
For Each window In shell.Windows
If window = "Windows Explorer" Then
path = Mid(window.LocationURL, 9)
Select Case path
Case "D:/", "D:/a"
window.Quit
End Select
End If
Next
Windows 7下窗口可以分成Windows Internet Explorer、Windows Explorer两种,前者是IE窗口,后者是Explorer窗口,但是在Windows 2003中没有作区分,只有Windows Internet Explorer一种窗口,所以上面代码的If条件不成立。
既然这样,就不加If判断了
'Author: Demon
'Website: http://demon.tw
'Date: 2011/7/11
Option Explicit
Dim shell, window, path
Set shell = CreateObject("Shell.Application")
For Each window In shell.Windows
path = Mid(window.LocationURL, 9)
Select Case path
Case "D:/", "D:/a"
window.Quit
End Select
Next