Internet explorer 正在读取internet explorer临时文件夹中的文件
我有一个VBScript,可以导航到Internet Explorer页面,该页面在我的临时Internet文件夹中存储一个名为“123.txt”的文件。在这个文本文件中,有一行内容是“Key=1234567”。我正在尝试创建一个脚本,用于检索该键并将其显示在消息框中。我的问题是临时文件夹是一个虚拟文件夹,不能像普通文件那样读取文件Internet explorer 正在读取internet explorer临时文件夹中的文件,internet-explorer,vbscript,virtualfilesystem,Internet Explorer,Vbscript,Virtualfilesystem,我有一个VBScript,可以导航到Internet Explorer页面,该页面在我的临时Internet文件夹中存储一个名为“123.txt”的文件。在这个文本文件中,有一行内容是“Key=1234567”。我正在尝试创建一个脚本,用于检索该键并将其显示在消息框中。我的问题是临时文件夹是一个虚拟文件夹,不能像普通文件那样读取文件 Const TEMPORARY_INTERNET_FILES = &H20& Dim WshShell = CreateO
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
Const临时互联网文件=&H20&
Dim WshShell=CreateObject(“WScript.Shell”)
Dim objShell=CreateObject(“Shell.Application”)
Dim objFolder=objShell.Namespace(临时互联网文件)
Dim objFolderItem=objFolder.Self
Dim ie=CreateObject(“InternetExplorer.Application”)
可见=真实
ie.navigate2(“myUrl”)
趁忙
wscript.Sleep(1)
结束时
dimfasstreamreader
Dim colItems=objFolder.Items
对于每个对象,在colitem中
如果InStr(objItem.name,“123.txt”)为0,则
Dim sr As StreamReader=新StreamReader(Str(objFolderItem.path&“\”&objItem.name))
当sr.Peek()>=0时执行此操作
尺寸线=高级读线()
如果(仪表(线,“键”)为0,则
键=线
如果结束
环
如果结束
下一个
msgbox键看起来您正在使用VB.NET。下面是一个VBScript示例:
' Get the path to the temporary internet files folder...
strPath = objShell.Namespace(TEMPORARY_INTERNET_FILES).Self.Path
' Create an FSO...
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check for the file's existence...
If objFSO.FileExists(strPath & "\123.txt") Then
' Read the first line...
strLine = objFSO.OpenTextFile(strPath & "\123.txt").ReadLine()
' Split on '=' and display the second array element...
MsgBox Split(strLine, "=")(1)
End If
实际上,临时Internet文件中的文件通常被重命名。因此,使用shell接口,它将使用您认为它具有的名称 这与您可以在“资源管理器详细信息”视图中打开的列相同 此脚本转储文件夹中对象的所有外壳属性。确实如此
Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")
'32 is Temp Internet Files
Set Fldr=objShell.NameSpace(32)
'Set Fldr=objShell.NameSpace(Ag(0))
Set FldrItems=Fldr.Items
Set fso = CreateObject("Scripting.FileSystemObject")
Set DeskFldr=objShell.Namespace(16)
FName=fso.buildpath(DeskFldr.self.path, "Folder Property List.txt")
Set ts = fso.OpenTextFile(FName, 8, true)
'Getting first 40 column names by passing null
For x = 0 to 40
t1 = t1 & Fldr.GetDetailsOf(vbnull, x) & vbtab
Next
ts.write FLDR.self.path & vbcrlf
ts.Write T1 & vbcrlf
T1=""
'getting the first 40 column values for each item
For Each FldrItem in FldrItems
For x = 0 to 40
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbtab
Next
t1=t1 & vbcrlf
ts.Write T1
T1=""
Next
msgbox FName & "has a tab delimited list of all properties"