Querying NT

Querying NT

Is there a way to query NT 4.0 (programmatically or manually) to have it tell me whether it is NT workstation or NT server? Is the answer in the system registry or in the OS itself?

Yes, the following code should work for you. Note that this assumes that anything that isn’t a NT server is a NT workstation, so if that’s not true, you might want some further checks and a return of other than a boolean value.


Option Explicit' Constants for type of computerPrivate Enum enumServerType   SV_TYPE_WORKSTATION = &H1&   SV_TYPE_SERVER = &H2&   SV_TYPE_SQLSERVER = &H4&   SV_TYPE_DOMAIN_CTRL = &H8&   SV_TYPE_DOMAIN_BAKCTRL = &H10&   SV_TYPE_NOVELL = &H80&   SV_TYPE_NT = &H1000&   SV_TYPE_WFW = &H2000&   SV_TYPE_SERVER_NT = &H8000&   SV_TYPE_WINDOWS = &H400000   SV_TYPE_ALL = &HFFFFEnd Enum' Type used by NetServerGetInfo and NetServerSetInfoPrivate Type SERVER_INFO_101    sv101_platform_id As Long    sv101_name As Long    sv101_ver_major As Long    sv101_ver_minor As Long    sv101_type As Long    sv101_comment As LongEnd Type      ' API declarationsPrivate Declare Function NetServerGetInfo _   Lib "Netapi32" _      (sServerName As Byte, _       ByVal lLevel As Long, _       vBuffer As Long) As LongPrivate Declare Function NetApiBufferFree _   Lib "netapi32.dll" _   (ByVal lngPtrBuffer As Long) As LongPrivate Declare Function lstrlenW _   Lib "kernel32" _   (ByVal lpString As Long) As LongPublic Declare Sub CopyMem _   Lib "kernel32" Alias "RtlMoveMemory" _   (dest As Any, vSrc As Any, ByVal lSize As Long)Public Sub Main()   Debug.Print IsServer("")   Debug.Print IsServer("PDCNew")End SubPublic Function IsServer(Optional ByVal xi_strServerName As String = "") As Boolean   Dim p_bytServerName()         As Byte   Dim p_lngRtn                  As Long   Dim p_lngSrvInfoRtn           As Long   Dim p_typServerInfo101        As SERVER_INFO_101   Dim p_lngServEnumLevel        As Long      ' Initialize the variables   If Trim$(xi_strServerName) = vbNullString Then      p_bytServerName = vbNullChar   Else      p_bytServerName = Trim$(xi_strServerName) & vbNullChar   End If   p_lngServEnumLevel = 101     ' Call NetServerEnum to get a list of Servers   If Trim$(xi_strServerName) = vbNullString Then      p_lngRtn = NetServerGetInfo(sServerName:=ByVal p_bytServerName(0), _                                  lLevel:=p_lngServEnumLevel, _                                  vBuffer:=p_lngSrvInfoRtn)   Else      p_lngRtn = NetServerGetInfo(sServerName:=p_bytServerName(0), _                                  lLevel:=p_lngServEnumLevel, _                                  vBuffer:=p_lngSrvInfoRtn)   End If      If p_lngRtn = 0 Then      ' xxx      CopyMem p_typServerInfo101, _              ByVal p_lngSrvInfoRtn, _              Len(p_typServerInfo101)      If p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_SERVER_NT Then         IsServer = True      ElseIf p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_DOMAIN_BAKCTRL Then         IsServer = True      ElseIf p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_DOMAIN_CTRL Then         IsServer = True      Else         IsServer = False      End If         Else      Debug.Print "Error: " & Err.LastDllError   End If   End Function

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as