I have A VBScript that navigates to an Internet Explorer page which stores a file called "123.txt" in my Temp internet Folder. In this text file is a line that reads "Key=1234567" I am trying to make a script that retrieves this key and displays it in a message box. My problem is that the temp folder is a virtual folder and the files cannot be read like a normal file.
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
msgbox key
As files in Temp Internet Files are usually renamed in reality. Therefore use the shell interfaces which will use the name you think it has.
This is the same as the columns you can turn on in Explorer details view.
This script dumps all shell properties for a objects in a folder. It does TIF.