You can get the logon type using the Windows API without WMI --
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <NTSecAPI.h>
#pragma comment(lib, "secur32")
#include <stdio.h>
#include <memory>
PCWSTR GetLogonTypeAsString(SECURITY_LOGON_TYPE type)
{
switch (type)
{
case UndefinedLogonType: return L"UndefinedLogonType";
case Interactive: return L"Interactive";
case Network: return L"Network";
case Batch: return L"Batch";
case Service: return L"Service";
case Proxy: return L"Proxy";
case Unlock: return L"Unlock";
case NetworkCleartext: return L"NetworkCleartext";
case NewCredentials: return L"NewCredentials";
case RemoteInteractive: return L"RemoteInteractive";
case CachedInteractive: return L"CachedInteractive";
case CachedRemoteInteractive: return L"CachedRemoteInteractive";
case CachedUnlock: return L"CachedUnlock";
default: return L"Error";
}
}
int main()
{
DWORD dwLength{};
GetTokenInformation(GetCurrentProcessToken(), TokenStatistics, nullptr, 0, &dwLength);
std::unique_ptr<BYTE[]> buffer = std::make_unique<BYTE[]>(dwLength);
if (GetTokenInformation(GetCurrentProcessToken(), TokenStatistics, buffer.get(), dwLength, &dwLength))
{
PTOKEN_STATISTICS pts = reinterpret_cast<PTOKEN_STATISTICS>(buffer.get());
PSECURITY_LOGON_SESSION_DATA pLogonSessionData{};
auto status = LsaGetLogonSessionData(&pts->AuthenticationId, &pLogonSessionData);
if (status == 0)
{
wprintf_s(L"Logon type was %s\n", GetLogonTypeAsString((SECURITY_LOGON_TYPE) pLogonSessionData->LogonType));
LsaFreeReturnBuffer(pLogonSessionData);
}
}
return 0;
}