Function funCreateRegKey(sComputer As String) As Boolean
Dim regHKLM As RegistryKey
Dim regHive As RegistryHive
Try
regHKLM = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, sComputer)
Catch ex As Exception
Return False
End Try
Dim asd2 As RegistryKey
Try
asd2 = regHKLM.OpenSubKey("SYSTEM\CurrentControlSet\services\eventlog\Microsoft-Windows-TerminalServices-Gateway/Operational", True)
Catch ex As Exception
End Try
If asd2 IsNot Nothing Then
Debug.Print("Key exists")
Else
' debug.print("Key does not exist")
Try
Dim writekey As RegistryKey = regHKLM.OpenSubKey("SYSTEM\CurrentControlSet\services\eventlog", True)
writekey.CreateSubKey("Microsoft-Windows-TerminalServices-Gateway/Operational")
Catch ex As Exception
End Try
End If
'Dim asd = asd2.GetValue("PROCESSOR_ARCHITECTURE")
'debug.print(asd.ToString)
'funGetUsers = ""
'For Each oKeys As String In regHKLM.OpenSubKey("").GetSubKeyNames
'Next
End Function
Function funDeleteRegKey(sComputer As String) As Boolean
Dim regHKLM As RegistryKey
Dim regHive As RegistryHive
regHKLM = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, sComputer)
Dim asd2 As RegistryKey = regHKLM.OpenSubKey("SYSTEM\CurrentControlSet\services\eventlog\Microsoft-Windows-TerminalServices-Gateway/Operational", True)
If asd2 IsNot Nothing Then
' debug.print("Key exists")
'debug.print("Key does not exist")
Dim writekey As RegistryKey = regHKLM.OpenSubKey("SYSTEM\CurrentControlSet\services\eventlog", True)
writekey.DeleteSubKey("Microsoft-Windows-TerminalServices-Gateway/Operational")
Else
End If
'Dim asd = asd2.GetValue("PROCESSOR_ARCHITECTURE")
'debug.print(asd.ToString)
'funGetUsers = ""
End Function
Dim remoteEventLogs() As EventLog
Try
remoteEventLogs = EventLog.GetEventLogs(sMachineName.ToString)
Catch ex As Exception
Return
End Try
For Each log In remoteEventLogs
'debug.print(("Log: " & log.Log))
If log.Log = "Microsoft-Windows-TerminalServices-Gateway/Operational" Then
Debug.Print("FOUND")
Try
For Each oEntry As EventLogEntry In log.Entries
eventList.Add(oEntry)
catch
end try
end if
next