当前位置: 移动技术网 > IT编程>脚本编程>VBScript > vbs判读盘符被双击的脚本

vbs判读盘符被双击的脚本

2017年12月12日  | 移动技术网IT编程  | 我要评论

复制代码 代码如下:

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网