Computer Name WMI





2
Date Submitted Thu. Mar. 2nd, 2006 10:38 AM
Revision 1 of 1
Syntax Master dannyboy
Tags Hostname | VBSCRIPT | WMI
Comments 0 comments
Get computername with wmi

Function GetComputerName()
        On Error Resume Next
        Set OpSysSet = GetObject("winmgmts:\root\cimv2").ExecQuery("select * from Win32_ComputerSystem")
        For each i in OpSysSet
        ' There should only be one anyway, but we'll do this to be sure to be sure.
                GetComputerName = i.Name
        Next
End Function
 

Comments

There are currently no comments for this snippet.

Voting