none
A VBScript is not workin in my HTA RRS feed

  • Question

  • I am developing an HTA for my own networking purposes and I just want to know why this script works by itself but does not work in my HTA. I assigned it to a button using subroutine however when I click the button the script will not run.

    strComputer= "."
    Set objWMIService = GetObject( _
        "winmgmts:\\" & strComputer & "\root\cimv2")
    Set IPConfigSet = objWMIService.ExecQuery _
        ("Select IPAddress from Win32_NetworkAdapterConfiguration ")
     
    For Each IPConfig in IPConfigSet
        If Not IsNull(IPConfig.IPAddress) Then
            For i=LBound(IPConfig.IPAddress) _
                to UBound(IPConfig.IPAddress)
                    MsgBox( IPConfig.IPAddress(i))
            Next
        End If
    Next

    Wednesday, January 18, 2017 7:31 PM

Answers

  • You are missing an "=" sign.

    Until you learn start simple and format code so that it is readable:

    <html>
    <script language="VBScript">
    
    	Sub GetIPAddresses
    		MsgBox "We clicked"
    	End Sub
    
    </script>
    
    <body >
    	<input type="button" value="IP Addresses" name="run_button" onClick="GetIPAddresses">
    </body>
    </html>
    


    \_(ツ)_/

    Thursday, January 19, 2017 9:31 AM

All replies

  • Please post a short sample HTA that contains only the absolute minimum amount of code needed to reproduce the problem.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, January 18, 2017 8:03 PM
    Moderator
  • I push the button in GUI and nothing happens.

    <html>
    <head>
    <title>My HTML application</title>
    <HTA:APPLICATION
      APPLICATIONNAME="HTML Application"
      BORDERSTYLE = "normal"
      SINGLEINSTANCE = "yes"
      >
    </head>

    <script language="VBScript">

    Sub GetIPAddresses
    strComputer= "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set IPConfigSet = objWMIService.ExecQuery ("Select IPAddress from Win32_NetworkAdapterConfiguration ")
     
    For Each IPConfig in IPConfigSet
        If Not IsNull(IPConfig.IPAddress) Then
            For i=LBound(IPConfig.IPAddress) _
                to UBound(IPConfig.IPAddress)
                    MsgBox( IPConfig.IPAddress(i))
          Next 
        End If
    Next
    End Sub

    </script>

    <body bgcolor="white">
    <font size="4" color="black" face="Arial">Click Button:</font>
    <p></p>
    <input type="button" value="IP Addresses" name="run_button" onClick"GetIPAddresses">

    </body>
    </html>

    Thursday, January 19, 2017 4:19 AM
  • You are missing an "=" sign.

    Until you learn start simple and format code so that it is readable:

    <html>
    <script language="VBScript">
    
    	Sub GetIPAddresses
    		MsgBox "We clicked"
    	End Sub
    
    </script>
    
    <body >
    	<input type="button" value="IP Addresses" name="run_button" onClick="GetIPAddresses">
    </body>
    </html>
    


    \_(ツ)_/

    Thursday, January 19, 2017 9:31 AM
  • In the spirit of learning where am I missing an "=" sign? I am learning that's why I asked the question.


    • Edited by adam06 Tuesday, January 24, 2017 5:24 AM
    Tuesday, January 24, 2017 5:23 AM
  • <input type="button" value="IP Addresses" name="run_button" onClick"GetIPAddresses">

    http://w3schools.com


    \_(ツ)_/


    • Edited by jrv Tuesday, January 24, 2017 11:38 AM
    Tuesday, January 24, 2017 11:37 AM
  • Oh Ooops lol.

    Thursday, January 26, 2017 9:53 PM
  • Oh good lord

    Thursday, January 26, 2017 10:00 PM