Vbscript HTA浏览到文件
我正在尝试浏览文件 作为一个简单的vbs,它可以正常工作,但在HTA内部会产生错误 像这样:Vbscript HTA浏览到文件,vbscript,hta,Vbscript,Hta,我正在尝试浏览文件 作为一个简单的vbs,它可以正常工作,但在HTA内部会产生错误 像这样: sUserList = BrowseToFile msgbox sUserList Function BrowseToFile Set wShell=CreateObject("WScript.Shell") Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FIL
sUserList = BrowseToFile
msgbox sUserList
Function BrowseToFile
Set wShell=CreateObject("WScript.Shell")
Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE><script>FILE.click();new ActiveXObject(""Scripting.FileSystemObject"").GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""")
BrowseToFile = oExec.StdOut.ReadLine
End Function
我可以调用一个单独的vbs并写入文件,然后以这种方式获得它。错误的转义嵌套双引号:而不是
... new ActiveXObject(""Scripting.FileSystemObject"")...
使用单引号,如下所示:
... new ActiveXObject('Scripting.FileSystemObject')...
编辑:在你的HTATest.hta中,我看到一些奇怪的方法:
嵌套的。。。
从HTATest.hta启动mshta.exe,事实上,从mshta.exe HTATest.hta启动
下一个hta工作:
HTA Test Path=BrowseToFile msgbox Path=&Path函数BrowseToFile Set wShell=CreateObjectWScript.Shell Set oExec=wShell.Execmshta.exe关于:FILE.click;新的ActiveXObject'Scripting.FileSystemObject'.GetStandardStream1.WriteLineFILE.value;关树脂0,0;BrowseToFile=oExec.StdOut.ReadLine结束函数请不要在注释中发布代码片段,因为它会变得稍微不可读。请改为。HTA Test Path=BrowseToFile msgbox Path=&Path函数BrowseToFile Set wShell=CreateObjectWScript.Shell Set oExec=wShell.Execmshta.exe关于:FILE.click;新的ActiveXObject'Scripting.FileSystemObject'.GetStandardStream1.WriteLineFILE.value;关树脂0,0;BrowseToFile=oExec.StdOut.ReadLine结束函数Hi。。谢谢你。非常感谢。我会努力的,看看进展如何。
... new ActiveXObject('Scripting.FileSystemObject')...
<html>
<head>
<title>HTA Test
</title>
<HTA:APPLICATION ID="objTest" APPLICATIONNAME="HTATest" SCROLL="no" SINGLEINSTANCE="yes" >
</head>
<SCRIPT LANGUAGE="VBScript">
Path = BrowseToFile
msgboxx= "Path = " & Path
Function BrowseToFile()
Set wShell=CreateObject("WScript.Shell")
mshtapar="about:<input type=file id=FILE>"_
& "<script>FILE.click();"_
& "new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);"_
& "close();"_
& "resizeTo(0,0);"_
& "<//script>"
msgboxy= "param =" & mshtapar
Set oExec=wShell.Exec( "mshta.exe " & """" & mshtapar & """")
End Function
</SCRIPT>
<body>
</body>
<html>
<head>
<title>HTA Test
</title>
<HTA:APPLICATION ID="objTest" APPLICATIONNAME="HTATest" SCROLL="no" SINGLEINSTANCE="yes" >
</head>
<SCRIPT LANGUAGE="VBScript">
<!--
-->
</SCRIPT>
<body>
<input type="file" id=FILE>
</body>