我有一个 VBScript,它导航到 Internet Explorer 页面,该页面在我的 Internet 临时文件夹中存储了一个名为“123.txt”的文件。在此文本文件中有一行显示“Key=1234567”我正在尝试制作一个脚本来检索此密钥并将其显示在消息框中。我的问题是临时文件夹是一个虚拟文件夹,无法像普通文件一样读取文件。
Const TEMPORARY_INTERNET_FILES = &H20&
Dim WshShell = CreateObject("WScript.Shell")
Dim objShell = CreateObject("Shell.Application")
Dim objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
Dim objFolderItem = objFolder.Self
Dim ie = CreateObject("InternetExplorer.Application")
ie.visible = True
ie.navigate2("myUrl")
While (ie.busy)
wscript.Sleep(1)
End While
Dim f As StreamReader
Dim colItems = objFolder.Items
For Each objItem In colItems
If InStr(objItem.name, "123.txt") <> 0 Then
Dim sr As StreamReader = New StreamReader(Str(objFolderItem.path & "\" & objItem.name))
Do While sr.Peek() >= 0
dim line = sr.ReadLine()
if(instr(line,"key")<>0) then
key = line
end if
Loop
End If
Next
消息框键