当我运行代码时,出现错误
ActiveX组件无法创建对象:'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
答案 0 :(得分:1)
谢谢你。当我尝试运行一个简单的vbscript代码时,在我的Windows 7 64位机器上使用此Shell.Localmachine
时遇到同样的问题。我不得不默认为WScript.Network
:
'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
答案 1 :(得分:0)