Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Message on intranet 1

Status
Not open for further replies.

TommyF

Technical User
Oct 28, 2001
104
I have a very basic intranet system running at work which displayes the running order of our machines and I want to know if it is possiable to send a html popup message to certain users for example if the running order has changed. I don't want the users to have any interaction apart from closing the message.

Can anybody point me in the right direction please.

 
Thanks Tommy, will check the link

The prblem with books is that they tend to get outgrown pretty quickly. FOr that reason I would suggest a reference book rather than a how-to book.

THe only ASP book I have is "BEginning ASP databases" from wrox, but as I said, once I had the hang of it all, it wasnt much use.

There are some excellent websites with turorials out there, cheaper than books and you can ick what you want to look up.

My ASP book doesn't get used very much at all these days, on the other hand, I am constantly refering to my Javascript Bible and would suggest something like that instead.

Did you se my post a couple of days ago about the VBscript language reference tool? That is a great thing to have as well.

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
WooHoo!!!

My first Visual Basic programme ever is an incredible success - at least in my house.

A small .exe with a text box and a send button that sends the message to the other computer on the network. The IP# is hard coded, which limits it a bit, but it bloody works!

Thanks for the inspiration, I didn't even know "net send" existed.

OK, next project...an operating system :eek:)

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
Let's take this to the next level...

I also have created an in-house messanging utility using the above, but want to display a message if the user being netsend'd is not online.

I've tried using the .err collection, but no luck.

is there an event or a ?? associated with the wscript.shell object I can query after it tries to net send to see if the message was in fact sent successfully?

Cheers,

C

"Illegitimis non carborundum"
(don't let the b@st@rds get you down)
 
My guess is that with Net Send there is no response. It just tosses it out there and doesn't care what happens.

But, there must be a way of saying "is this IP alive". Maybe you can quietly ping first and look for the response. Can VB even do something like this? Anyone?

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
yes you can execute ping IP_ADDRESS and then read output why not ?
 
Here's a way of doin it component free...


Make a form with 1 command button (cmdExecute) and 1 text box (txtIP)

Insert the IP you need into the text box, and use this code:




Code:
Option Explicit
      
Private Declare Function CreatePipe Lib "kernel32" ( _
    phReadPipe As Long, _
    phWritePipe As Long, _
    lpPipeAttributes As Any, _
    ByVal nSize As Long) As Long
      
Private Declare Function ReadFile Lib "kernel32" ( _
    ByVal hFile As Long, _
    ByVal lpBuffer As String, _
    ByVal nNumberOfBytesToRead As Long, _
    lpNumberOfBytesRead As Long, _
    ByVal lpOverlapped As Any) As Long
      
Private Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Long
End Type

Private Type STARTUPINFO
    cb As Long
    lpReserved As Long
    lpDesktop As Long
    lpTitle As Long
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type
      
Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadID As Long
End Type

Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
    lpApplicationName As Long, ByVal lpCommandLine As String, _
    lpProcessAttributes As Any, lpThreadAttributes As Any, _
    ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
    ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
    lpStartupInfo As Any, lpProcessInformation As Any) As Long
      
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const STARTF_USESTDHANDLES = &H100&
Private Const STARTF_USESHOWWINDOW = &H1
Private Const SW_HIDE = 0

Private Sub cmdExecute_Click()
    Dim strPing As String
    Dim Reply As Long
    
    ' Ping IP Address
    strPing = ExecuteApp("cmd /c ping " & txtIP)
    
    ' If a reply was found set the position it was found
    Reply = 0
    Reply = InStr(4, strPing, "reply", 1)
    
    ' If the position of the reply is not equal to 0
    If Reply <> 0 Then
        Dim objNetSend
        objNetSend = Shell(&quot;C:\WINNT\SYSTEM32\CMD.EXE /c net send &quot; & txtIP & &quot; My Message Will Be Sent&quot;, 0)
    End If
End Sub

Private Function ExecuteApp(sCmdline As String) As String
    Dim proc As PROCESS_INFORMATION, ret As Long
    Dim start As STARTUPINFO
    Dim sa As SECURITY_ATTRIBUTES
    Dim hReadPipe As Long 'The handle used to read from the pipe.
    Dim hWritePipe As Long 'The pipe where StdOutput and StdErr will be redirected to.
    Dim sOutput As String
    Dim lngBytesRead As Long, sBuffer As String * 256

    sa.nLength = Len(sa)
    sa.bInheritHandle = True
      
    ret = CreatePipe(hReadPipe, hWritePipe, sa, 0)
    If ret = 0 Then
        MsgBox &quot;CreatePipe failed. Error: &quot; & Err.LastDllError
        Exit Function
    End If

    start.cb = Len(start)
    start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW
    ' Redirect the standard output and standard error to the same pipe
    start.hStdOutput = hWritePipe
    start.hStdError = hWritePipe
    start.wShowWindow = SW_HIDE
       
    ' Start the shelled application:
    ' if you program has to work only on NT you don't need the &quot;conspawn &quot;
    ret = CreateProcessA(0&, sCmdline, sa, sa, True, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
    If ret = 0 Then
        MsgBox &quot;CreateProcess failed. Error: &quot; & Err.LastDllError
        Exit Function
    End If
   
    ' The handle wWritePipe has been inherited by the shelled application
    ' so we can close it now
    CloseHandle hWritePipe

    ' Read the characters that the shelled application
    ' has outputed 256 characters at a time
    Do
        ret = ReadFile(hReadPipe, sBuffer, 256, lngBytesRead, 0&)
        sOutput = sOutput & Left$(sBuffer, lngBytesRead)
    Loop While ret <> 0 ' if ret = 0 then there is no more characters to read
    
    CloseHandle proc.hProcess
    CloseHandle proc.hThread
    CloseHandle hReadPipe

    ExecuteApp = sOutput ' Return the output of shelled program.
End Function


Let me know if you need anything explaining...


 
Glad to see this post is still going strong.

That looks like a good bit of code I will try it out.

 
Just an update to the previous code:

The line:

Reply = InStr(4, strPing, &quot;reply&quot;, 1)

should read:

Reply = InStr(1, strPing, &quot;reply&quot;, 1)
 
Microbe, could you point me to the thread relating to the VBscript language reference tool? you mention in this thread please

Regards

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top