J
James
vb.net 2003
i wrote a windows service that does threading. My codes are
a) the service thread will read a list of machine from a text file
(machines.txt).
b) it then logon using the below
Dim returnValue As Boolean = LogonUser(m_ntid, m_domain, m_pwd,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle)
if returnvalue = true
do part (c)
else
write a event log that computers do not exists
end if
c) once logon successful, it will do a wmi search for hotfix
Dim searchstring As String = "SELECT * FROM Win32_QuickFixEngineering WHERE
HotFixID = " & "'" & m_kbhotfix & "'"
Dim searcher As New ManagementObjectSearcher("\\" + computer +
"\root\CIMV2", searchstring)
if hotfix is found, then write an event log to my pc that runs the services.
It works fine for the following scenarios
1) the logon id is a administrator of remote machines
I deliberately setup some bogus machines in my machines.txt. By right these
machines do not exists. However the returnvalue always go to "true", which
mean "false" machines the thread ignore and do not write any event log. How
can i check machine exists first or can the code generate some try/catch
that machines do not exist or i do not have permission ? all i want is that
returnvalue = false so that my eventlogs can write something ?
i wrote a windows service that does threading. My codes are
a) the service thread will read a list of machine from a text file
(machines.txt).
b) it then logon using the below
Dim returnValue As Boolean = LogonUser(m_ntid, m_domain, m_pwd,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle)
if returnvalue = true
do part (c)
else
write a event log that computers do not exists
end if
c) once logon successful, it will do a wmi search for hotfix
Dim searchstring As String = "SELECT * FROM Win32_QuickFixEngineering WHERE
HotFixID = " & "'" & m_kbhotfix & "'"
Dim searcher As New ManagementObjectSearcher("\\" + computer +
"\root\CIMV2", searchstring)
if hotfix is found, then write an event log to my pc that runs the services.
It works fine for the following scenarios
1) the logon id is a administrator of remote machines
I deliberately setup some bogus machines in my machines.txt. By right these
machines do not exists. However the returnvalue always go to "true", which
mean "false" machines the thread ignore and do not write any event log. How
can i check machine exists first or can the code generate some try/catch
that machines do not exist or i do not have permission ? all i want is that
returnvalue = false so that my eventlogs can write something ?