复制代码 代码如下:

do while true 

set WshShell = WScript.CreateObject(“WScript.Shell”) 

IF WshShell.AppActivate(“D:\”) Then 

MsgBox “ok” 

wscript.quit 

End If 

loop 

试都不要试,就知道这段代码是错误的。因为WshShell.AppActivate考虑的是窗体的Caption中包含的字符或字符串,你用WshShell.AppActivate(“D:\”)这个,就是说窗体Caption里要包含”D:\”这个字符串。可你打开D盘看看,是这样的吗?都是“本地磁盘(D:)”。如果有卷标,那更说不准。所以应该写成WshShell.AppActivate(“(D:)”),考虑到内存节约的问题,应该这样写:

set WshShell = WScript.CreateObject(“WScript.Shell”)

do 

IF WshShell.AppActivate(“(D:)”) Then

MsgBox “ok”

wscript.quit

End If

loop

声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。