对象不支持此方法

时间:2019-04-11 14:35:56

标签: vbscript hta

我得到

  

对象不支持此方法

当我单击开始按钮时。它说那行是;

<input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button">

我相信它实际上可能在我的vbscript中。当我单击开始按钮时,它取决于是否输入了strPath并选中了复选框,它应该运行要安装的程序,或者告诉我我需要输入strPath或选中一个框

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tombstone USD #1 - Software Installer</title>

    <HTA:APPLICATION
        APPLICATIONNAME = "Software Installer"
        ICON = "images\districtlogo.ico"
        ID = "NAME"
        BORDER = "thick"        
        CAPTION = "yes"
        SHOWINTASKBAR = "yes"
        SINGLEINSTANCE = "yes"
        SYSMENU = "yes"
        WINDOWSTATE="normal"
        SCROLL = "no"
        VERSION = "1.0"
        INNERBORDER = "yes"
        SELECTION = "yes"
        MAXIMIZEBUTTON = "no"
        MINIMIZEBUTTON = "no"
        NAVIGABLE = "no"
        CONTEXTMENU = "yes"
        BORDERSTYLE = "normal"
    />

    <script type="text/javascript">
    <!--Resolution//-->
        window.resizeTo(600,750);
    </script>

    <script language="VBScript">
        Sub Start_Button()

            Dim strAnswer,strPath, objNetwork
            Set objNetwork = CreateObject("WScript.Network")
            strAnswer = ""
            strPath=""

            If chkEset.Checked Then strAnswer = "Eset"

            'If strPath is empty then nothing was checked.
            If strPath = "" Then 
                Window.Alert "Please input Path location!"
            End If

            'If strAnswer is empty then nothing was checked.
            If strAnswer = "" Then 
                Window.Alert "Please Make an Selection!"
                Exit Sub
            End If

            Window.Alert "Done!"
        End Sub
    </script>   

</head>

<body style="background-color:#E6E6FA">
    <center>
        <img src="images\districtlogo.png" alt="Logo" height="100" width="100"/>
        <h1>Software Installer</h1>
    </center>

    <form name="MainMenu" action="" method="">
        <label for="sPath">Drive Letter or File Path:</label><input type="text" size="60" id="sPath" name="sPath"></td>
        <br />
        <label for="Eset">ESet AntiVirus</label></td><input type="checkbox" id="Eset" name="chkEset">
        <br />
        <input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button"> 
        <br />
        <input type="reset" value="Reset">

    </form>

</body>

</html>

我目前正试图通过一个程序来运行该程序。这是概念验证测试。

1 个答案:

答案 0 :(得分:0)

好吧,既然我知道了,我想我会在下面添加完整的脚本。所做的全部工作就是检查strPath是否已填写以及复选框是否已选中。下一步是让它运行与复选框对应的程序。

我解决问题的方法是将<input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button">更改为<input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button()">

我还意识到,表单实际上并没有为脚本分配值,而是创建了TheForm值并将其分配给MainMenu表单。然后,我不得不将该值添加到所有现有值中。

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tombstone USD #1 - Software Installer</title>

    <HTA:APPLICATION
        APPLICATIONNAME = "Software Installer"
        ICON = "images\districtlogo.ico"
        ID = "NAME"
        BORDER = "thick"        
        CAPTION = "yes"
        SHOWINTASKBAR = "yes"
        SINGLEINSTANCE = "yes"
        SYSMENU = "yes"
        WINDOWSTATE="normal"
        SCROLL = "no"
        VERSION = "1.0"
        INNERBORDER = "yes"
        SELECTION = "yes"
        MAXIMIZEBUTTON = "no"
        MINIMIZEBUTTON = "no"
        NAVIGABLE = "no"
        CONTEXTMENU = "yes"
        BORDERSTYLE = "normal"
    />

    <script type="text/javascript">
    <!--Resolution//-->
        window.resizeTo(600,750);
    </script>

    <script language="VBScript">
        Sub Start_Button()

            Dim strAnswer,strPath, objNetwork,TheForm
            Set objNetwork = CreateObject("WScript.Network")
            Set TheForm = Document.MainMenu
            strAnswer = ""
            strPath = ""

            If TheForm.chkEset.Checked Then strAnswer = "Eset"            

           'If strPath is empty then nothing was checked.
            If TheForm.strPath = "" Then 
                Window.Alert "Please input Path location!"
                Exit Sub            
            End If

            'If strAnswer is empty then nothing was checked.
            If strAnswer = "" Then 
                Window.Alert "Please Make an Selection!"
                Exit Sub
            End If

            Window.Alert "Done!"
        End Sub
    </script>   

</head>

<body style="background-color:#E6E6FA">
    <center>
        <img src="images\districtlogo.png" alt="Logo" height="100" width="100"/>
        <h1>Software Installer</h1>
    </center>

    <form name="MainMenu" action="" method="">
        <label for="Path">Drive Letter or File Path:</label><input type="text" size="60" id="Path" name="strPath"></td>
        <br />
        <label for="Eset">ESet AntiVirus</label></td><input type="checkbox" id="Eset" name="chkEset">
        <br />
        <input type="button" name="btnStart" id="btnStart" value="Start" onclick="Start_Button()"> 
        <br />
        <input type="reset" value="Reset">

    </form>

</body>

</html>