How to get System Names which are connected in Network?

Dear Friends,
  How to get the system Names which are connected in network using API and How to Shut down the system from Remote.
Thanks In advance
Who is Participating?
sdm395Connect With a Mentor Commented:

Both on the WinNt Resource Kit.  Shutdown.exe is a command line utility (you must have admin rights) which you could shell out to....

also this from vbnet - enumerates machines on the network

' Copyright ?1996-2001 VBnet, Randy Birch, All Rights Reserved.
' Terms of use 

'Windows type used to call the Net API
Private Const MAX_PREFERRED_LENGTH As Long = -1
Private Const NERR_SUCCESS As Long = 0&
Private Const ERROR_MORE_DATA As Long = 234&

Private Const SV_TYPE_WORKSTATION         As Long = &H1
Private Const SV_TYPE_SERVER              As Long = &H2
Private Const SV_TYPE_SQLSERVER           As Long = &H4
Private Const SV_TYPE_DOMAIN_CTRL         As Long = &H8
Private Const SV_TYPE_DOMAIN_BAKCTRL      As Long = &H10
Private Const SV_TYPE_TIME_SOURCE         As Long = &H20
Private Const SV_TYPE_AFP                 As Long = &H40
Private Const SV_TYPE_NOVELL              As Long = &H80
Private Const SV_TYPE_DOMAIN_MEMBER       As Long = &H100
Private Const SV_TYPE_PRINTQ_SERVER       As Long = &H200
Private Const SV_TYPE_DIALIN_SERVER       As Long = &H400
Private Const SV_TYPE_XENIX_SERVER        As Long = &H800
Private Const SV_TYPE_NT                  As Long = &H1000
Private Const SV_TYPE_WFW                 As Long = &H2000
Private Const SV_TYPE_SERVER_MFPN         As Long = &H4000
Private Const SV_TYPE_SERVER_NT           As Long = &H8000
Private Const SV_TYPE_POTENTIAL_BROWSER   As Long = &H10000
Private Const SV_TYPE_BACKUP_BROWSER      As Long = &H20000
Private Const SV_TYPE_MASTER_BROWSER      As Long = &H40000
Private Const SV_TYPE_DOMAIN_MASTER       As Long = &H80000
Private Const SV_TYPE_SERVER_OSF          As Long = &H100000
Private Const SV_TYPE_SERVER_VMS          As Long = &H200000
Private Const SV_TYPE_WINDOWS             As Long = &H400000  'Windows95 and above
Private Const SV_TYPE_DFS                 As Long = &H800000  'Root of a DFS tree
Private Const SV_TYPE_CLUSTER_NT          As Long = &H1000000 'NT Cluster
Private Const SV_TYPE_TERMINALSERVER      As Long = &H2000000 'Terminal Server
Private Const SV_TYPE_DCE                 As Long = &H10000000'IBM DSS
Private Const SV_TYPE_ALTERNATE_XPORT     As Long = &H20000000'rtn alternate transport
Private Const SV_TYPE_LOCAL_LIST_ONLY     As Long = &H40000000'rtn local only
Private Const SV_TYPE_DOMAIN_ENUM         As Long = &H80000000
Private Const SV_TYPE_ALL                 As Long = &HFFFFFFFF

Private Const SV_PLATFORM_ID_OS2       As Long = 400
Private Const SV_PLATFORM_ID_NT        As Long = 500

'Mask applied to svX_version_major in
'order to obtain the major version number.
Private Const MAJOR_VERSION_MASK        As Long = &HF

Private Type SERVER_INFO_100
  sv100_platform_id As Long
  sv100_name As Long
End Type

Private Declare Function NetServerEnum Lib "Netapi32" _
  (ByVal servername As Long, _
   ByVal level As Long, _
   buf As Any, _
   ByVal prefmaxlen As Long, _
   entriesread As Long, _
   totalentries As Long, _
   ByVal servertype As Long, _
   ByVal domain As Long, _
   resume_handle As Long) As Long

Private Declare Function NetApiBufferFree Lib "netapi32.dll" _
   (ByVal Buffer As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" _
   Alias "RtlMoveMemory" _
  (pTo As Any, uFrom As Any, _
   ByVal lSize As Long)
Private Declare Function lstrlenW Lib "kernel32" _
  (ByVal lpString As Long) As Long  

Private Sub Form_Load()

   Command1.Caption = "Net Server Enum"

End Sub

Private Sub Command1_Click()

   Call GetServers(vbNullString)
End Sub

Private Function GetServers(sDomain As String) As Long

  'lists all servers of the specified type
  'that are visible in a domain.
   Dim bufptr          As Long
   Dim dwEntriesread   As Long
   Dim dwTotalentries  As Long
   Dim dwResumehandle  As Long
   Dim se100           As SERVER_INFO_100
   Dim success         As Long
   Dim nStructSize     As Long
   Dim cnt             As Long

   nStructSize = LenB(se100)
  'Call passing MAX_PREFERRED_LENGTH to have the
  'API allocate required memory for the return values.
  'The call is enumerating all machines on the
  'network (SV_TYPE_ALL); however, by Or'ing
  'specific bit masks for defined types you can
  'customize the returned data. For example, a
  'value of 0x00000003 combines the bit masks for
  'SV_TYPE_WORKSTATION (0x00000001) and
  'SV_TYPE_SERVER (0x00000002).
  'dwServerName must be Null. The level parameter
  '(100 here) specifies the data structure being
  'used (in this case a SERVER_INFO_100 structure).
  'The domain member is passed as Null, indicating
  'machines on the primary domain are to be retrieved.
  'If you decide to use this member, pass
  'StrPtr("domain name"), not the string itself.
   success = NetServerEnum(0&, _
                           100, _
                           bufptr, _
                           MAX_PREFERRED_LENGTH, _
                           dwEntriesread, _
                           dwTotalentries, _
                           SV_TYPE_ALL, _
                           0&, _

  'if all goes well
   If success = NERR_SUCCESS And _
      success <> ERROR_MORE_DATA Then
    'loop through the returned data, adding each
    'machine to the list
      For cnt = 0 To dwEntriesread - 1
        'get one chunk of data and cast
        'into an SERVER_INFO_100 struct
        'in order to add the name to a list
         CopyMemory se100, ByVal bufptr + (nStructSize * cnt), nStructSize
         List1.AddItem GetPointerToByteStringW(se100.sv100_name)
   End If
  'clean up regardless of success
   Call NetApiBufferFree(bufptr)
  'return entries as sign of success
   GetServers = dwEntriesread

End Function

Public Function GetPointerToByteStringW(ByVal dwData As Long) As String
   Dim tmp() As Byte
   Dim tmplen As Long
   If dwData <> 0 Then
      tmplen = lstrlenW(dwData) * 2
      If tmplen <> 0 Then
         ReDim tmp(0 To (tmplen - 1)) As Byte
         CopyMemory tmp(0), ByVal dwData, tmplen
         GetPointerToByteStringW = tmp
     End If
   End If
End Function

Hope this helps

N_K_venkatAuthor Commented:
Dear sdm395 ,
  Hi here is my problem i am having nearly 10 machines which are in my network.I want some code to shut down all the machines in my network thru VB coding(from the server).
From the code which u gave just now i am unable to Find the machine names Under My network.if its there please post it
waiting for Ur Reply
Thanks in advance
N_K_venkatAuthor Commented:
Dear sdm395 ,
  Hi here is my problem i am having nearly 10 machines which are in my network.I want some code to shut down all the machines in my network thru VB coding(from the server).
From the code which u gave just now i am unable to Find the machine names Under My network.if its there please post it
waiting for Ur Reply
Thanks in advance
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Add a command button (command1) and a list box (list1) to a form in a standard exe.  Copy the code, and then run it - when you click the button you should get a list of the machines on your network.  

If you do, then you can replace the

 List1.AddItem GetPointerToByteStringW(se100.sv100_name)

line and replace it with a shell to the shutdown.exe
(I can't remember the switches you need)

Otherwise let me know what you get.
Richie_SimonettiIT OperationsCommented:
To enumerate network resources you can use WNet for VB from

To shutdown remote machine you can use WinAPI. However the remote shutdown doesn't work always -- you can find the descriptions of known problems in MSDN.

The best way to guarantee the remote shutdown is to lunch a service on remote mashine which will perform shutdown locally. However it requires much more code...
N_K_venkatAuthor Commented:
Dear mike1234 ,
  where from U?and where are Working ?In that snark soft???
Dear N K venkat,
I'm from Russia, I'm not working for that company.
N_K_venkatAuthor Commented:
Dear mike1234 ,
i am from India.How is the market there?if u dont mind please give me ur personal id
Bye from
Richie_SimonettiIT OperationsCommented:
Hi _K_venkat, any progress on this?
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
POINTS FOR EXPERTS awaiting comments are listed in the link below
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.