获取主机名的vbs,需要的朋友可以参考下。
代码如下:
strComputer = "."
Set objCmdLib = CreateObject("Microsoft.CmdLib")
Set objCmdLib.ScriptingHost = WScript.Application
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
WScript.Echo objCmdLib.getHostName(objWMIService)