如何检测是否运行在微软的虚拟机中(代码)
2007-11-03 00:29:21 来源:WEB开发网核心提示:' 如何检测是否运行在微软的虚拟机环境的脚本程序代码'' 下面是微软推荐的检测是否运行在微软虚拟机中的代码' 有需要的人可以参考借鉴' 属于VBscript脚本语言编写' --Dim ManufacturerstrComputer = "."Set o
' 如何检测是否运行在微软的虚拟机环境的脚本程序代码
'
' 下面是微软推荐的检测是否运行在微软虚拟机中的代码
' 有需要的人可以参考借鉴
' 属于VBscript脚本语言编写
' ----------------------------------------------------------
Dim Manufacturer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
Manufacturer = objItem.Manufacturer
Next
if Manufacturer = "Microsoft Corporation" then
wscript.echo "In Microsoft virtual machine"
else
wscript.echo "Not in Microsoft virtual machine"
end if
'
' 下面是微软推荐的检测是否运行在微软虚拟机中的代码
' 有需要的人可以参考借鉴
' 属于VBscript脚本语言编写
' ----------------------------------------------------------
Dim Manufacturer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
Manufacturer = objItem.Manufacturer
Next
if Manufacturer = "Microsoft Corporation" then
wscript.echo "In Microsoft virtual machine"
else
wscript.echo "Not in Microsoft virtual machine"
end if
更多精彩
赞助商链接