SoFunction
Updated on 2025-04-10

vbs script that reads disk letters double-clicked

Copy the codeThe code is as follows:

do while true 
set WshShell = ("") 
IF ("D:\") Then 
MsgBox "ok" 
 
End If 
loop 

Don't even try, just know that this code is wrong. Because you are considering the characters or strings contained in the form Caption, you use ("D:\") to mean that the form Caption should include the string "D:\". But you open the D drive and see, is that true? All are "local disks (D:). If there is a label, it is even more inaccurate. So it should be written as ("(D:)"). Considering the memory saving issue, it should be written like this:

set WshShell = ("")
do 
IF ("(D:)") Then
MsgBox "ok"

End If
loop