473,503 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending a message to another computer -how?

Bob
Vb.net 2005. I need to send a message to a computer named Comp1 on my LAN. I
need window to pop up, much like when a network admin sends a message to
some users that the network will shut down for maintenance. But I need to do
it for one particular computer whose name I know and I need to do it from
within VB.NET 2005 code.
I think I should use the system.messaging namespace but I can't figure out
the sequence. Is there some sample code out there that does this? Looked but
did not find.

Thanks for any help.

Bob
Jan 30 '06 #1
5 8165
CMM
If you're looking to send an NT alert to a user (like you describe) and you
know the Alerter/Messenger services (no, not Windows Messenger) are running
on the other computer you can:

1) Use "net send" command:
Process.Start(Environment.GetEnvironmentVariable(" COMSPEC"),String.Format("/c
net send {0} \"{1}\"", target, msg));

or

2) Look into using the NetMessageBufferSend API p/invoke. It's very easy to
use:
P.S.
I don't think System.Messaging is at all what you're looking for. That deals
with MSMQ and is not a "messaging" thingy as you know it but rather a way
for applications to send data to each other.

"Bob" <bd*****@sgiims.com> wrote in message
news:ex**************@TK2MSFTNGP10.phx.gbl...
Vb.net 2005. I need to send a message to a computer named Comp1 on my LAN.
I need window to pop up, much like when a network admin sends a message to
some users that the network will shut down for maintenance. But I need to
do it for one particular computer whose name I know and I need to do it
from within VB.NET 2005 code.
I think I should use the system.messaging namespace but I can't figure out
the sequence. Is there some sample code out there that does this? Looked
but did not find.

Thanks for any help.

Bob

Jan 31 '06 #2
you could also use , if your app was on both computers, sockets and network
streams to send and receive text, then display whatever was received in a
Messagebox
--
-iwdu15
Jan 31 '06 #3
Bob
Thanks, the app is a service that resides on one computer and we don't want
to install anything special on the other computers to keep maintenance task
to a minimum. So I'm leaning towards using the net send command.
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:C3**********************************@microsof t.com...
you could also use , if your app was on both computers, sockets and
network
streams to send and receive text, then display whatever was received in a
Messagebox
--
-iwdu15

Jan 31 '06 #4
CMM
Check out this code... it encapsulates the NetMessage API so you don't have
to spawn a CommandPrompt to do it. It's actually very very simple:
Imports System.Runtime.InteropServices

Public Class NTAlerter

Private m_sFrom As String = String.Empty
Private m_sBody As String = String.Empty
Private m_sTo As String = String.Empty
Private m_sWhere As String = String.Empty

Private Class Win32

<DllImport("netapi32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName As
String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Long) As Int32
End Function

End Class

Public Property From() As String
Get
Return m_sFrom
End Get
Set(ByVal Value As String)
m_sFrom = Value
End Set
End Property

Public Property Body() As String
Get
Return m_sBody
End Get
Set(ByVal Value As String)
m_sBody = Value
End Set
End Property

Public Property [To]() As String
Get
Return m_sTo
End Get
Set(ByVal Value As String)
m_sTo = Value
End Set
End Property

Public Property Where() As String
Get
Return m_sWhere
End Get
Set(ByVal Value As String)
m_sWhere = Value
End Set
End Property

Public Function Send() As Integer

Dim sTo As String
Dim sFrom As String
Dim sWhere As String
Dim sBody As String
Dim iResult As Integer

If m_sTo = String.Empty Then
sTo = vbNullString
Else
sTo = m_sTo
End If

If m_sFrom = String.Empty Then
sFrom = vbNullString
Else
sFrom = m_sFrom
End If

If m_sWhere = String.Empty Then
sWhere = vbNullString
Else
sWhere = m_sWhere
End If

If m_sBody.Length > 0 And m_sTo.Length > 0 Then
sBody = Left(m_sBody, 255)
iResult = Win32.NetMessageBufferSend(sWhere, sTo, sFrom, sBody,
sBody.Length * 2)
Return iResult
End If

End Function

End Class


"Bob" <bd*****@sgiims.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Thanks, the app is a service that resides on one computer and we don't
want to install anything special on the other computers to keep
maintenance task to a minimum. So I'm leaning towards using the net send
command.
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:C3**********************************@microsof t.com...
you could also use , if your app was on both computers, sockets and
network
streams to send and receive text, then display whatever was received in a
Messagebox
--
-iwdu15


Jan 31 '06 #5
Bob
Thanks, I"ll give it a shot
Bob

"CMM" <cm*@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Check out this code... it encapsulates the NetMessage API so you don't
have to spawn a CommandPrompt to do it. It's actually very very simple:
Imports System.Runtime.InteropServices

Public Class NTAlerter

Private m_sFrom As String = String.Empty
Private m_sBody As String = String.Empty
Private m_sTo As String = String.Empty
Private m_sWhere As String = String.Empty

Private Class Win32

<DllImport("netapi32.dll", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal lpServerName As
String, _
ByVal lpMsgName As String, ByVal lpFromName As String, _
ByVal lpBuf As String, ByVal lnBufLen As Long) As Int32
End Function

End Class

Public Property From() As String
Get
Return m_sFrom
End Get
Set(ByVal Value As String)
m_sFrom = Value
End Set
End Property

Public Property Body() As String
Get
Return m_sBody
End Get
Set(ByVal Value As String)
m_sBody = Value
End Set
End Property

Public Property [To]() As String
Get
Return m_sTo
End Get
Set(ByVal Value As String)
m_sTo = Value
End Set
End Property

Public Property Where() As String
Get
Return m_sWhere
End Get
Set(ByVal Value As String)
m_sWhere = Value
End Set
End Property

Public Function Send() As Integer

Dim sTo As String
Dim sFrom As String
Dim sWhere As String
Dim sBody As String
Dim iResult As Integer

If m_sTo = String.Empty Then
sTo = vbNullString
Else
sTo = m_sTo
End If

If m_sFrom = String.Empty Then
sFrom = vbNullString
Else
sFrom = m_sFrom
End If

If m_sWhere = String.Empty Then
sWhere = vbNullString
Else
sWhere = m_sWhere
End If

If m_sBody.Length > 0 And m_sTo.Length > 0 Then
sBody = Left(m_sBody, 255)
iResult = Win32.NetMessageBufferSend(sWhere, sTo, sFrom, sBody,
sBody.Length * 2)
Return iResult
End If

End Function

End Class


"Bob" <bd*****@sgiims.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Thanks, the app is a service that resides on one computer and we don't
want to install anything special on the other computers to keep
maintenance task to a minimum. So I'm leaning towards using the net send
command.
"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
news:C3**********************************@microsof t.com...
you could also use , if your app was on both computers, sockets and
network
streams to send and receive text, then display whatever was received in
a
Messagebox
--
-iwdu15




Feb 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1579
by: Edwin Rozie | last post by:
Hey can U help me with the following? I would like to send basic data (like a set of integers & strings) from one php function to another php function. Sounds easy, However, the functions are...
1
2547
by: VM | last post by:
Where can I get information on building a web application that can send, via the Web, a text message to a portable device or another computer? And where can I get information on sending the same...
7
1592
by: Paul Wilson | last post by:
Guys, I would like a notification module for my simple ASP application. What i want to do is simple & as follows, 1). When the user adds some data into the system (VB.Net on the server side...
10
599
by: herbert | last post by:
I am a hotmail user. 1) How do I send e-mail from my .NET 2.0 app via hotmail? How should the following lines look like? Assume my hotmail username is HMUN, my hotmail password is HMPW. Dim...
8
2830
by: Michel Posseth [MCP] | last post by:
Hi does someone has experience with this ?? i have made a lot of apps in the past that were capable of sending e-mails the server i then talked to was a Linux SMTP server and it worked great ...
2
7623
by: nautonnier | last post by:
Hello, I have a C# app that spawns several processes each containing a console app written by another developer in C++. The console app was written first to be just like a console app: it...
2
1630
by: luchyloo | last post by:
-------------------------------------------------------------------------------- What you have to implement You have a message that can be sent on a port. Before sending the message you have to...
0
951
by: ruchikagupta | last post by:
i m trying sending mails from the asp.net web application the code is running fine on another computer but if i run the same code on my system then it throws an exception "Failure Sending Mail" the...
1
2963
by: Jeff Williams | last post by:
I have an application using dial monitors which is used in an aution room. The auctioneer has a form showing details of the current lot number. As he changes to the next lot number I need to...
13
2336
by: ofiras | last post by:
Hello everyone, How can I sand a post to a web page? I want that when the page is trying to fetch a post variable, it will be something the program defined first. Please help, Ofir.
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.