Code Error 800A01A8 - Object Required

22,511

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")
Share:
22,511
Root Loop
Author by

Root Loop

Updated on February 27, 2020

Comments

  • Root Loop
    Root Loop over 4 years

    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?