Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Vbs代码在hta中不工作_Html_Windows_Windows 7_Vbscript_Hta - Fatal编程技术网

Html Vbs代码在hta中不工作

Html Vbs代码在hta中不工作,html,windows,windows-7,vbscript,hta,Html,Windows,Windows 7,Vbscript,Hta,我在这里有以下vbscript代码: Set fso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") Sub Write Set oFile = fso.OpenTextFile("Text.txt",8,true) oFile.close Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.R

我在这里有以下vbscript代码:

Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Sub Write
Set oFile = fso.OpenTextFile("Text.txt",8,true)
oFile.close
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "m1.hta"
End Sub
这将生成一个文本文件并启动m1.hta,它可以完美地工作。但是,当我将其放入hta文件时,如下所示:

<Script Language="VBscript">
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Sub Write
Set oFile = fso.OpenTextFile("Text.txt",8,true)
oFile.close
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "m1.hta"
End Sub
</Script>
<input type="Button" value="GO" onclick="Write">

设置fso=CreateObject(“Scripting.FileSystemObject”)
设置objShell=CreateObject(“WScript.Shell”)
子写入
Set of ile=fso.OpenTextFile(“Text.txt”,8,true)
关闭
设置WshShell=WScript.CreateObject(“WScript.Shell”)
WshShell.Run“m1.hta”
端接头
我似乎得到了这个错误:


我的问题首先是代码出了什么问题,其次是如何修复它。提前感谢。

WScript.CreateObject(“WScript.Shell”)
替换为此
CreateObject(“WScript.Shell”)
HTA文件使用
mshta.exe
运行脚本
mshta.exe
无法识别
wscript
对象。这就是导致该错误的原因

运行
.vbs
文件时,将使用
wscript.exe
,它将完美地运行代码

因此,从代码中删除
wscript
应该可以正常工作