Code Error 800A01A8 - Object Required

陌路散爱 提交于 2020-01-03 05:16:08

问题


I have a HTA file that open a text box alows user to enter path to a folder then save it to a text file.

But when I trying to use second button to run a batch, it gives me an error code

Code Error 800A01A8 - Object Required : 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>

I can't find out why....did some research but no luck at all Any suggestion?


回答1:


The WScript object your line

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

tries to use does not exist in a HTA (it is provided by the w|cscript.exe hosts). As VBScript (the language itself) provides its own CreateObject function, just use

Set WshShell = CreateObject("WScript.Shell")



回答2:


You need a trailing \ on your replacement text else you have DataAppData

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

Also response.write is for ASP ...



来源:https://stackoverflow.com/questions/22043691/code-error-800a01a8-object-required

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!