• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2190
  • Last Modified:

Use visual basic to send colour message over the LAN

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
barnesa
Asked:
barnesa
  • 9
  • 9
  • 4
  • +1
1 Solution
 
aflat362Commented:
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
 
barnesaAuthor Commented:
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
 
aflat362Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CycLonECommented:
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
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
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
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
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
 
aflat362Commented:
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
 
aflat362Commented:
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
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
Hi bhagyesht

I have spoken to the person and he is happy with getting the message in a browser window on his screen.
0
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
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
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
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
 
bhagyeshtCommented:
are u able to browse to the computer? ie through your windows explorer try browsing once you run
net use
0
 
barnesaAuthor Commented:
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
 
bhagyeshtCommented:
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
 
barnesaAuthor Commented:
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
 
barnesaAuthor Commented:
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
 
bhagyeshtCommented:
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
 
bhagyeshtCommented:
Glad could help!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 9
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now