【问题标题】:Code Error 800A01A8 - Object Required代码错误 800A01A8 - 需要对象
【发布时间】:2014-02-26 14:01:52
【问题描述】:

我有一个 HTA 文件,它打开一个文本框,允许用户输入文件夹的路径,然后将其保存到文本文件中。

但是当我尝试使用第二个按钮运行批处理时,它给了我一个错误代码

代码错误 800A01A8 - 需要对象:Wscript

    <html>
<head>
<title>Files Sync </title>
<HTA:APPLICATION
  APPLICATIONNAME="Files Sync"
  ID="RY"
  VERSION="1.0"/>
</head>

<script language="vbscript">

Sub WriteTxt_OnClick()
    Dim fso, txt

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set txt = fso.CreateTextFile("\\fs-02\C$\ntfs3\scripts\MexSync\000.txt")

    txt.WriteLine document.Submitted_Link_To_Mex.body.value

    MsgBox "File Submitted",64,"Selection"


End Sub

Sub SYNC_onClick()

     Set WshShell = WScript.CreateObject("WScript.Shell")
     WshShell.Run "cmd.exe /c C:\work\RLTP_SYNC_MEX\RunChangePS1.bat", 0
            ' 0 => hide
     MsgBox("Success")

End Sub



</script>


<H2>Copy And Paste The Folder Path To Here </H2>
<body>


<form name="Submitted_Link_To_Mex">
<textarea name="body" cols="150" rows="20">

</textarea>
</form>




<br>
    <input type="button" value="1. SUBMIT" name="WriteTxt"> &nbsp; &nbsp; &nbsp;
    <input type="Button" value="2. SYNC" name="SYNC"> &nbsp; &nbsp; &nbsp;
    <input type="Button" value="3. CLOSE" name="button2" onClick="close" class="button">
</div>

</body>
</html>

我不知道为什么....做了一些研究,但完全没有运气 有什么建议吗?

【问题讨论】:

    标签: vbscript hta


    【解决方案1】:

    你的行的 WScript 对象

    Set WshShell = WScript.CreateObject("WScript.Shell")
    

    尝试使用的 HTA 中不存在(它由 w|cscript.exe 主机提供)。由于 VBScript(语言本身)提供了自己的 CreateObject 函数,因此只需使用

    Set WshShell = CreateObject("WScript.Shell")
    

    【讨论】:

      【解决方案2】:

      你需要在你的替换文本后面加上\,否则你有DataAppData

      Replace(txt, "K:\", "D:\Data\")
      

      另外response.write 用于 ASP ...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多