By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,115 Members | 898 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,115 IT Pros & Developers. It's quick & easy.

how to check computername exists, before logon remotely

P: n/a
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 ?




Jan 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

List Computers in network with api
http://www.vb-tips.com/default.aspx?...8-dad5ea63a743

List computers in network with active directory classes
http://www.vb-tips.com/default.aspx?...3-9c76953e41cf

Ken
----------------
"James" <jk****@hotmail.com> wrote in message
news:eQ*************@tk2msftngp13.phx.gbl...
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
?




Jan 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.