Shell object in html embaded vbscript

Author Message
robiee4u

  • Total Posts : 36
  • Scores: 0
  • Reward points : 0
  • Joined: 10/6/2004
  • Location:
  • Status: offline
Shell object in html embaded vbscript Monday, March 07, 2005 12:03 AM (permalink)
0
I am new in this forum. I have a vbscript which I want to use in html.
Now when I try this, I found an error to create a shell object and the error message is "ActiveX control can't create object".
is it not possible to create and use this kinda object in embaded html?
Please help
 
#1
    robiee4u

    • Total Posts : 36
    • Scores: 0
    • Reward points : 0
    • Joined: 10/6/2004
    • Location:
    • Status: offline
    Re: Shell object in html embaded vbscript Monday, March 07, 2005 12:07 AM (permalink)
    0
    To make the problem clear let me provide the code.

    <html>
    <head>
    <title>Trouble Shooting Tool for Helpdesk</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/vbscript">
    Sub IP()
    'Option Explicit
    On Error resume Next
    Dim o_sehllobj, result, outPut
    set o_sehllobj = CreateObject("Wscript.Shell") ' <.....i am having the error here...>
    if(err.number<>0) Then
    msgbox (Err.Description)
    End If
    result = o_sehllobj.Exec("ping uk911dp6008")
    outPut = ""
    Do While result.StdOut.AtEndOfStream <> True
    outPut = outPut + result.StdOut.ReadLine
    Loop
    Dim oRE, oMatches
    oRE = New RegExp
    oRE.Global = True
    oRE.IgnoreCase = True
    oRE.Pattern = "[0-9]+.[0-9]+.[0-9]+.[0-9]+"
    set oMatches = oRE.Execute(outPut)
    Dim oMatch
    For Each oMatch In oMatches
    'textfield2.Text = oMatch.Value
    msgbox(oMatch.Value)
    Exit For
    Next
    End Sub
    </script>
    </head>

    <body bgcolor="#FFFFFF">

    <div id="Layer1" style="position:absolute; left:207px; top:25px; width:414px; height:20px; z-index:1"></div>
    <div id="Layer2" style="position:absolute; left:157px; top:55px; width:549px; height:70px; z-index:2">
    <form name="form1" >
    <p>Computer Name:
    <input type="text" name="textfield">
    <INPUT TYPE="Button" NAME="Button1" VALUE="Click">
    <SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
    call IP()
    </SCRIPT>

    IP Address
    <input type="text" name="textfield2">
    </p>
    </form>
    </div>
    <div id="Layer3" style="position:absolute; left:51px; top:145px; width:873px; height:17px; z-index:3">
    <hr>
    </div>
    <div id="Layer4" style="position:absolute; left:53px; top:188px; width:881px; height:490px; z-index:4"></div>
    </body>
    </html>
     
    #2
      mbouchard

      • Total Posts : 2110
      • Scores: 29
      • Reward points : 0
      • Joined: 5/15/2003
      • Location: USA
      • Status: offline
      Re: Shell object in html embaded vbscript Monday, March 07, 2005 12:22 AM (permalink)
      0
      I think that you need to change <script type="text/vbscript"> to <script language="VBscript">
       
      #3
        robiee4u

        • Total Posts : 36
        • Scores: 0
        • Reward points : 0
        • Joined: 10/6/2004
        • Location:
        • Status: offline
        Re: Shell object in html embaded vbscript Monday, March 07, 2005 12:44 AM (permalink)
        0
        i did change it but didn't make any difference. plz help
         
        #4
          beaker

          • Total Posts : 82
          • Scores: 0
          • Reward points : 0
          • Joined: 1/27/2005
          • Location: USA
          • Status: offline
          Re: Shell object in html embaded vbscript Monday, March 07, 2005 1:02 AM (permalink)
          0
          1. Comment out your troublesome line 'set o_sehllobj = CreateObject("Wscript.Shell")' and get rid of the variable 'o_sehllobj'.
          2. Above the <script language="vbscript"> tag, place the following line:
          <object classid="clsid:{72C24DD5-D70A-438B-8A42-98424B88AFB8}" id="o_sehllobj"></object>
          3. Use the object 'o_sehllobj' as normal in code. You don't need to change anything else.
           
          #5
            robiee4u

            • Total Posts : 36
            • Scores: 0
            • Reward points : 0
            • Joined: 10/6/2004
            • Location:
            • Status: offline
            Re: Shell object in html embaded vbscript Monday, March 07, 2005 2:02 AM (permalink)
            0
            thanx for you reply. But when I do the changes you asked i get an error that is:
            "object doesnt support this method or property" in the following line.
            set result = o_sehllobj.Exec("ping uk911dp6008")
             
            #6
              Snipah

              • Total Posts : 1339
              • Scores: 8
              • Reward points : 0
              • Joined: 11/1/2004
              • Location: Scotland
              • Status: offline
              Re: Shell object in html embaded vbscript Monday, March 07, 2005 2:50 AM (permalink)
              0
              set o_sehllobj = New ActiveXObject("WScript.Shell")

               
              #7
                robiee4u

                • Total Posts : 36
                • Scores: 0
                • Reward points : 0
                • Joined: 10/6/2004
                • Location:
                • Status: offline
                Re: Shell object in html embaded vbscript Monday, March 07, 2005 3:08 AM (permalink)
                0
                any idea about why when I use the Option Explicit statment my vbscript doesnt run in the example given in this topic.
                 
                #8
                  robiee4u

                  • Total Posts : 36
                  • Scores: 0
                  • Reward points : 0
                  • Joined: 10/6/2004
                  • Location:
                  • Status: offline
                  Re: Shell object in html embaded vbscript Monday, March 07, 2005 3:42 AM (permalink)
                  0
                  And the script is returing my intended result in a msgbox (the code is provided up there), but when I m tring to assign this value to a textfield (which is declared in the html block) something like this :
                  textfield.Text = oMatch.Value
                  an error is occuring that object required. Seems that the script is not getting the textfield as a object Any idea plz.
                   
                  #9
                    beaker

                    • Total Posts : 82
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 1/27/2005
                    • Location: USA
                    • Status: offline
                    Re: Shell object in html embaded vbscript Monday, March 07, 2005 8:51 AM (permalink)
                    0
                    quote:
                    thanx for you reply. But when I do the changes you asked i get an error that is:
                    "object doesnt support this method or property" in the following line.
                    set result = o_sehllobj.Exec("ping uk911dp6008")

                    This tells me that you are now past the original problem, which means you are now creating the object successfully. The new problem looks to me like the parameter to the 'Exec' function is wrong. A lot of regulars here are expert on how to 'ping' from script, so I defer to them.
                    quote:
                    any idea about why when I use the Option Explicit statment my vbscript doesnt run in the example given in this topic.

                    Yes, you have a variable or variables in use without declaring them with the 'Dim' statement.
                     
                    #10
                      token

                      • Total Posts : 1917
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 1/14/2005
                      • Location:
                      • Status: offline
                      Re: Shell object in html embaded vbscript Monday, March 07, 2005 11:21 AM (permalink)
                      0
                      hmmm.. I couldn't see anything wrong with the EXEC method :\

                      robiee4u, why don't you try to lower the security settings for the Local Intranet Zone so that it could run the scripts for all sites defined in the zone ?
                       
                      #11
                        robiee4u

                        • Total Posts : 36
                        • Scores: 0
                        • Reward points : 0
                        • Joined: 10/6/2004
                        • Location:
                        • Status: offline
                        Re: Shell object in html embaded vbscript Monday, March 07, 2005 9:21 PM (permalink)
                        0
                        yes, its working when i lower the security settings. Thanx.
                         
                        #12
                          token

                          • Total Posts : 1917
                          • Scores: 0
                          • Reward points : 0
                          • Joined: 1/14/2005
                          • Location:
                          • Status: offline
                          Re: Shell object in html embaded vbscript Tuesday, March 08, 2005 6:22 AM (permalink)
                          0
                          woohoo. Finally!. No problem. ;D
                           
                          #13

                            Online Bookmarks Sharing: Share/Bookmark

                            Jump to:

                            Current active users

                            There are 0 members and 1 guests.

                            Icon Legend and Permission

                            • New Messages
                            • No New Messages
                            • Hot Topic w/ New Messages
                            • Hot Topic w/o New Messages
                            • Locked w/ New Messages
                            • Locked w/o New Messages
                            • Read Message
                            • Post New Thread
                            • Reply to message
                            • Post New Poll
                            • Submit Vote
                            • Post reward post
                            • Delete my own posts
                            • Delete my own threads
                            • Rate post

                            2000-2012 ASPPlayground.NET Forum Version 3.9