-1

This vbs code show error when I click to execute it

Set objIP = CreateObject( "SScripting.IPNetwork" )
strIP = objIP.DNSLookup( "www.google.com" )
WScript.Echo "IP address of www.google.com: " & strIP
Set objIP = Nothing

The error is here in this is pic.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    Possible duplicate of [ActiveX component can't create object](http://stackoverflow.com/questions/656934/activex-component-cant-create-object) – user692942 Nov 25 '15 at 19:47

2 Answers2

1

It seems to me that activeX components are often poorly documented and if you can't get stuff working, you need a method that bypasses the documentation and goes directly to what you've actually got available on you machine.

I had documentation that said something like:

Set library = CreateObject("somethinglibLib.SomethingLibrary.2")

would work, it didn't... where now?

I found that the "somethinglibLib.SomethingLibrary.2" should exist in the registry in a ProgID key, if it doesn't your CreateObject won't work.

I won't cover the cases where you haven't registered the activeX component as that is covered elsewhere.

But if you search the registry for part of the object name you are looking for, you may find as I did a ProgId containing

"somethinglib.SomethingSite.1"

knowing this I found

Set library = CreateObject("somethinglib.SomethingSite.1")

worked

Now my example is due partly to the version I had installed not matching the documentation, but hopefully this technique may help others.

slfan
  • 8,950
  • 115
  • 65
  • 78
martski
  • 342
  • 1
  • 5
-2

In order to make your code working, you need to make sure you have System Scripting Runtime installed on your machine.

Here is very good reference for that.

ManishChristian
  • 3,759
  • 3
  • 22
  • 50
  • It's more likely that the COM library `SScripting.IPNetwork` is not installed / registered. If the runtime wasn't installed you wouldn't get that error in the first place as the script wouldn't run period. – user692942 Nov 25 '15 at 19:44
  • First of all the the code he is showing is not complete code, so whatever is before it, will run, and will throw the error once reach to the beginning of these lines. – ManishChristian Nov 25 '15 at 19:50
  • The fact the OPs code is not complete has no bearing on whether the Scripting Runtime is installed. If the `cscript.exe` or `wscript.exe` weren't installed nothing would run and you certainly wouldn't get a `CreateObject()` error. – user692942 Nov 26 '15 at 09:00
  • no this is only the script no more all what i want is resolve the ip from the host name in vbs script – Mohmed Medhat Nov 26 '15 at 17:12