Solved

Use visual basic to send colour message over the LAN

Posted on 2003-11-03
23
2,175 Views
Last Modified: 2013-12-04
I am currently writing an application in visual basic that updates real-time data on our intranet, but what I need to be able to do is to send an alert message to one of our users if the data goes above or below a certain value, so that they can check the web page.  The web page is not always open, so I need it to work through something like the messenger service, although I'm not sure how to add the colour part.

If the value goes over a certain amount I need the alert to appear in blue and if the alert goes below a certain amount I need the alert to appear as red.

Is there any way of doing this through visual basic?
0
Comment
Question by:barnesa
  • 9
  • 9
  • 4
  • +1
23 Comments
 
LVL 3

Expert Comment

by:aflat362
ID: 9672429
Wouldn't an email message be better?  Messenger service pop ups can be dismissed without the user even reading it.  Plus you can provide a link in the email making it easier for the user.  And you will have a records of the message being sent - the user will have records of having recieved it.
0
 

Author Comment

by:barnesa
ID: 9672510
The user receives about 100-200 a day and he has said that he doesn't want to receive it as an email.

I am getting around the problem just now by using the net send command in visual basic, but net send doesn't have the capabilities to send the message as coloured text or with a coloured background and it can only send off the message one at a time.
0
 
LVL 3

Expert Comment

by:aflat362
ID: 9672929
Here's an idea . . Have a VB program run on the Client's computer.  Have IT do the reads / logic / whatever that will decide whether to tell him about it.
Then you can send pop ups on his local machine.  you will have more control over appearance this way.  For example if you can't get MsgBox to be in color (no idea if you can)  Than have 2 different forms with different colors and show the forms with an OK box.
0
 
LVL 1

Expert Comment

by:CycLonE
ID: 9676872
well
u can use winsock control to send data over network.

this data can then be parsed as required.
for example using the winsock control:

<blue>msg...whatever...</blue>
<red>msg...oh my god...</red>

have vb then read and parse each msg and display each msg in its specified color.

* using winsock you can send any type of data. for example send 3 bytes to describe 3 status like:
1st byte = critical
2nd byte= permanent
3rd byte = ignore

or u can send 1 byte using its bits saving bandwidth and space... (if your familiar with the binary and bit system)
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9676884
another way will be to use psexec to invoke a webpage on the user's pc the webpage can have the message in what ever colour you want.
like
psexec \\<machinename> -i cmd.exe /c start http://www.google.com

you need the admin previlages on that machine. you can provide the username and the password in the command line too.

you can download psexec from www.sysinternals.com its a freeware
0
 

Author Comment

by:barnesa
ID: 9730641
I should have said at the start that the user has about 700 rows on the webpage so the alert needs to say:

1) what row has been affected.
2) what the value has now changed to
3) the text in red if the value has gone down
4) the text in blue if the value has gone up

I am currently using net send to tell him what row has been affected and what the new value is, but I can't send the text in red/blue colour with a net send command.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9730706
you can open the page by sending accross an url with # and the bookmark of javascript so that the page will automatically show the selected row.
like
http://www.experts-exchange.com/Programming/Q_20786328.html#9730641 takes you to your answer
0
 

Author Comment

by:barnesa
ID: 9731172
Although the user has to go into the webpage and look at the details, he does not want the webpage popping up in any shape or form to show him the alert.

Is there any programs/vb out there that allows an user to see the value like a net send command prompt but with the text in colour?  
0
 
LVL 3

Expert Comment

by:aflat362
ID: 9731277
Not that I know of - or anyone else participating in this thread evidently.  This is why were offering all these alternatives.

Here's one more:

The user wants a quick visual clue as to whether a value goes up or down.  what if you just put the word UP or DOWN or somthing like that INCREASE DECREASE whatever in all caps - they should see it right away - same net effect as the colors I guess.
0
 
LVL 3

Expert Comment

by:aflat362
ID: 9731296
Or . . . Does the client use Instant Messenger or ICQ or something like that?  Maybe you could send him a message using that . .  Not sure how to do it but I'm sure it wouldn't be that difficult.

OR  . . . yet another solution.  . . Program a new web page that summarizes changes - print your changes in red or blue and make it flexible for the user - show the last 20, last 50.

I can't imagine that your user is so particular that they must have a pop up message come up on their computer and that it must be blue or red or whatever.

Yet another suggestion:  Write a client program to reside on the client computer, Have it recieve messages from the other program and have it display the popup - this way you could make the pop ups look however you want.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9737118
if he doesnt want the webpage popping up is it ok for him to get the message in a browser window? if yes use DCOM to invoke a browser and write to the DOM of the browser if its ok tell me i'll provide the code.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:barnesa
ID: 9738320
Hi bhagyesht

I have spoken to the person and he is happy with getting the message in a browser window on his screen.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9738691
ok copy and paste the code below into a text file rename the file with a vbs extention

now on the computer where u wish to show the message goto start menu->run and run the dcomcnfg.exe A window will appear.
in the application tab select Internet explorer and click on properties button now go to the identity tab and select interactive user. save ur changes by clicking ok and closing the application.

now run the script you shall get the message on the computer



make appropriate changes as required ie call using the proper computername, colorname and message



'code begins
call ShowMessage(<Computername>,<color>,<message>)


function ShowMessage(strComputerName,strColor,strMessage)
      Dim IE
      Set IE = CreateObject("InternetExplorer.Application",strComputername)
      IE.height=100
      IE.width=300
      IE.toolbar=false
      IE.menubar=false
      IE.statusbar=false
      IE.navigate "about:blank"
      IE.visible=1
      'wait a while until IE as finished to load
      Do while IE.busy
      loop
      Do While UCase(IE.Document.readyState) <> "COMPLETE"
            WScript.Sleep 100
         DoEvents
      Loop
      IE.document.write("<head><title>New Message for you</title></head>")
      IE.document.write("<body bgcolor=" + strColor + " >" + strMessage + "</body>")
      set IE=nothing
      'IE.Quit
end function


'code ends
0
 

Author Comment

by:barnesa
ID: 9740673
bhagyesht, this bit of code is brillant and it is exactly what I need.

The only problem I have got is that I can get it to run on the local computer perfectly, but when I try to send it to the remote computer it keeps coming back with permission denied.

I have checked the dcomcnfg and that is configured properly as per you instructions above on the remote computer, any other things that might be stopping it from working on the remote machine.
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 500 total points
ID: 9745171
first before executing the code you need to login to the machine using the username and password of the user thats logged in you can do so by using the net command assuming the username is abcd and the password is defg you can login to the machine by the following piece of code.
this is because we need to run the program in the active client's desktop


' code starts
      Dim WshShell
      Set WshShell = CreateObject("WScript.Shell")
      WshShell.Run "cmd /c net use \\<computername> /USER:abcd defg",0,true
      set WshShell=nothing
' code ends
0
 

Author Comment

by:barnesa
ID: 9747022
I have added the code in with the correct computername, username and password but it keeps coming back with permission denied on the following line:

     Set IE = CreateObject("InternetExplorer.Application", strComputerName)

It only seems to want to run it on the local machine
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9747039
are u able to browse to the computer? ie through your windows explorer try browsing once you run
net use
0
 

Author Comment

by:barnesa
ID: 9747420
I am able to browse to the computer's c$ share as the computer I am using is a domain administrator

The code runs ok and displays the message on the other computer when the 2 machines are both logged in as the same user account.  I have tried running the wsHSell.Run command below from the dos prompt and that returns the commands has completed successfully

cmd /c net use \\<computername> /USER:<user> <pass>

0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9761320
I assume both the OS are win2k right?
one silly question: are u using the username as that who is logged in on the remote computer?
ie if userA has logged on to computer1 and you have logged on to computer2 as userB from computerB you want to run the program your command would be
cmd /c net use \\computer1 /USER:userA userAPassword
0
 

Author Comment

by:barnesa
ID: 9769894
Yes both the OS are win2k and I am doing as you say about using the currently logged in user's details on the remote machine as part of the script.
0
 

Author Comment

by:barnesa
ID: 9771952
bhagyesht, thanks for your help with this.

I have managed to get this to work on both the machines with the win2k systems now, I wasn't giving the code enough time to log into the remote computer.

Do you know if this code works with windows nt as well, the reason for this is so that I can script the code to alert on a different screen at weekends that runs windows nt workstation?
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9776230
it should work on 98 and windows nt 4.0 with the latest service pack. 95 will require DCOM98 to be installed and IE5.5 onwards
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9776232
Glad could help!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now