Cocoa Dev
Cocoa Dev

Reputation: 9541

It keeps saying ActiveX component can't create object: 'Shell.LocalMachine'

When I run the code, I get an error saying

ActiveX component can't create object: 'Shell.LocalMachine'

Class MachineName
    Private internal_ComputerName

    Public Function SetMachineName
        Set objComputer = CreateObject("Shell.LocalMachine")
        internal_ComputerName = objComputer.MachineName
    End Function

    Public Property Get GetMachineName
        GetMachineName = internal_ComputerName
    End Property
End Class

Dim objMachine
Set objMachine = New MachineName
objMachine.SetMachineName

Upvotes: 0

Views: 3801

Answers (2)

Michael
Michael

Reputation: 11

thanks for this. I am having the same problems when using this Shell.Localmachine on my windows 7 64 bit machine when i try to run a simple vbscript code. I had to default to WScript.Network instead:

'just a test script
'set objComputer = CreateObject("Shell.LocalMachine")

'wscript.echo "computer name" & objcomputer.machinename

Set objWshNet = CreateObject("WScript.Network")
wscript.echo "computer name : " & objwshnet.computername

Upvotes: 1

Cocoa Dev
Cocoa Dev

Reputation: 9541

Morbo said "Must admit I hadn't come across that object before. I'd normally create a "WScript.Network" object and get the ComputerName property. If you're diagnosing "Shell.LocalMachine" I can tell you that on my copy of XP it is provided by system32\shgina.dll"

Upvotes: 0

Related Questions