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开发者_JAVA技巧_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
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
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"
精彩评论