Re: NET SEND by harrykrishna
harrykrishna
Fri Nov 30 09:53:55 PST 2007
"Rafael T" <okinawapro@hotmail.com> wrote:
>Gazza,
>
>Use the WScript.Shell object to be able to do external calls.
>then use the object.run to pass the command in a form like
>
>cmd net send address message
>
>hope this helps, but if you need more info, ask
I used something like the attached for a simple net send hta app.
It's missing the .ico and .gif file but will give you an idea of what
you might want to try.
Save everything between the XXXXX as a document with an .hta
extension, then double-click to try it out. Notice some of the text
wraps so clean that up 1st.
Hope it helps....
XXXXXXXXXXXX
<HTML>
<!----------------------------------------------------------------------
'
----------------------------------------------------------------------
' File: NetSend.hta
' Created: February 2005
' Version: 1.0
' Author: HKV
' Description: GUI Front-End to NET SEND Command.
'
----------------------------------------------------------------------
'
---------------------------------------------------------------------->
<HEAD>
<TITLE>Sample Net Send</TITLE>
<HTA:APPLICATION
APPLICATIONNAME = "Send NetMessage"
BORDER = "dialog"
BORDERSTYLE = "normal"
CAPTION = "yes"
CONTEXTMENU = "no"
ICON = "NetSend.ico"
ID = "HKVApp"
INNERBORDER = "no"
MAXIMIZEBUTTON = "no"
MINIMIZEBUTTON = "yes"
NAVIGABLE = "no"
SCROLL = "no"
SCROLLFLAT = "yes"
SELECTION = "no"
SHOWINTASKBAR = "yes"
SINGLEINSTANCE = "yes"
SYSMENU = "yes"
VERSION = "1.0"
WINDOWSTATE = "normal"
>
<OBJECT ID="WindowsShell"
CLASSID="clsid:13709620-C279-11CE-A49E-444553540000"></OBJECT>
<!----------------------------------------------------------------------
' VBS CODE GOES HERE
---------------------------------------------------
'
---------------------------------------------------------------------->
<SCRIPT LANGUAGE="VBScript">
Dim MessageTo, ProblemNo, MessageFrom, PhoneNo, ExtraText,
FullMessage, WshShell
Set WshShell = CreateObject("WScript.Shell")
Window.ResizeTo 320, 550
Window.MoveTo 350, 80
Sub BuildMessage
Set MyForm = Document.hkv
MessageTo = MyForm.MessageTo.Value
ProblemNo = MyForm.ProblemNo.Value
MessageFrom = MyForm.MessageFrom.Value
PhoneNo = MyForm.PhoneNo.Value
ExtraText = MyForm.ExtraText.Value
<!--- Strip out extra spaces in MessageTo (if any) and then check to
ensure it is not blank: --->
LenMessageTo = Len(MessageTo)
For i = LenMessageTo to 2 Step -1
strChars = Space(i)
MessageTo = Replace(MessageTo, strChars, " ")
Next
If MessageTo = "" or MessageTo = " " Then
MsgBox "You must enter a computer name. ",vbExclamation,"Send
Message To:"
Exit Sub
End If
<!--- No Broadcast messages allowed: --->
If MessageTo = "*" Then
MsgBox "Sending broadcast messages (*) is not permitted. " &
vbCrLf &_
"Please try again.",vbExclamation,"Broadcast not
permitted."
Exit Sub
End If
If ProblemNo = "" or ProblemNo = " " Then
MsgBox "You must enter a Problem Number.
",vbExclamation,"Problem Number:"
Exit Sub
End If
If MessageFrom = "" or MessageFrom = " " Then
MsgBox "You must enter your name. ",vbExclamation,"My Name:"
Exit Sub
End If
If PhoneNo = "" or PhoneNo = " " Then
MsgBox "You must enter your telephone number.
",vbExclamation,"My Telephone:"
Exit Sub
End If
If ExtraText = "" Then
ECHOExtraText = "&&@ECHO. "
ELSE
ECHOExtraText = "&&@ECHO " & ExtraText
End If
ECHOMessage = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
& _
"&&ECHO. " & _
"&&@ECHO ================================================"
&_
"&&@ECHO PLEASE CALL REGARDING PROBLEM NUMBER " &
ProblemNo & ": " & _
"&&@ECHO ================================================"
& _
"&&@ECHO. &&@ECHO " & MessageFrom & " at " & PhoneNo & "
A.S.A.P." & _
"&&@ECHO. " & _
ECHOExtraText & _
"&&@ECHO ================================================"
& _
"&&@ECHO Thank you." & "&&@ECHO. " & _
"&&ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
FullMessage = "====================================== " &
CHR(20) &_
"PLEASE CALL REGARDING PROBLEM NUMBER " & ProblemNo & ": "
& CHR(20) & _
"====================================== " & CHR(20) &
CHR(20) & _
MessageFrom & _
" at " & PhoneNo & " A.S.A.P." & CHR(20) & CHR(20) & _
ExtraText & CHR(20) & _
"====================================== " & CHR(20) & _
"Thank you."
WshShell.Run ("%ComSpec% /T:2E /K TITLE " & MessageTo & "|@ECHO
Attempting to send message to " & _
MessageTo & ": && ECHO. && ECHO." & _
ECHOMessage & "&& ECHO. && PAUSE|NET SEND " & MessageTo & " "
& FullMessage), 1, False
End Sub
Sub ExitHTA
Set WshShell = Nothing
Window.Close
End Sub
</SCRIPT>
</HEAD>
<!----------------------------------------------------------------------
' HTML BODY GOES HERE
--------------------------------------------------
'
---------------------------------------------------------------------->
<BODY BGCOLOR="#000080">
<FORM NAME="hkv">
<TABLE BORDER="0" WIDTH="100%" BGCOLOR="#000080">
<TR>
<TD WIDTH="210"><IMG BORDER="0" SRC="NetSend.gif" WIDTH="200"
HEIGHT="36"></TD>
<TD><B><FONT FACE="Arial" SIZE="1" COLOR="#FFFFFF">SAMPLE NET
SEND</FONT></B></TD>
</TR>
</TABLE>
<HR>
<TABLE CELLSPACING="1" CELLPADDING="5" WIDTH="292" ALIGN="LEFT"
BORDER="0" HEIGHT="69">
<TR>
<TD VALIGN="TOP" BGCOLOR="#996699"><B><FONT COLOR="#FFFFFF"
FACE="Arial" SIZE="2">Send Message To :</FONT></B></TD>
<TD VALIGN="TOP" BGCOLOR="#D4F1B9" HEIGHT="33"><INPUT
ID="MessageTo" SIZE="18" MAXLENGTH="18"></TD>
</TR>
<TR>
<TD VALIGN="TOP" BGCOLOR="#996699" WIDTH="130"><B><FONT
COLOR="#FFFFFF" FACE="Arial" SIZE="2">Problem Number :</FONT></B></TD>
<TD VALIGN="TOP" BGCOLOR="#D4F1B9" WIDTH="136" HEIGHT="33"><INPUT
ID="ProblemNo" SIZE="18" MAXLENGTH="18"></TD>
</TR>
</TABLE>
<BR><BR><BR><BR>
<TABLE CELLSPACING="1" CELLPADDING="5" WIDTH="292" ALIGN="LEFT"
BORDER="0" HEIGHT="69">
<TR>
<TD VALIGN="TOP" BGCOLOR="#996699"><B><FONT COLOR="#FFFFFF"
FACE="Arial" SIZE="2">My Name :</FONT></B></TD>
<TD VALIGN="TOP" BGCOLOR="#D4F1B9" HEIGHT="33"><INPUT
ID="MessageFrom" SIZE="18" MAXLENGTH="18"></TD>
</TR>
<TR>
<TD VALIGN="TOP" BGCOLOR="#996699" WIDTH="132"><B><FONT
COLOR="#FFFFFF" FACE="Arial" SIZE="2">My Telephone :</FONT></B></TD>
<TD VALIGN="TOP" BGCOLOR="#D4F1B9" HEIGHT="33" WIDTH="137"><INPUT
ID="PhoneNo" SIZE="18" MAXLENGTH="23"></TD>
</TR>
</TABLE>
<BR><BR><BR><BR>
<TABLE CELLSPACING="1" CELLPADDING="5" WIDTH="292" ALIGN="LEFT"
BORDER="0" HEIGHT="29">
<TR>
<TD VALIGN="TOP" BGCOLOR="#996699" WIDTH="280"
HEIGHT="33"><B><FONT FACE="Arial" SIZE="2" COLOR="#FFFFFF">Optional
Extra Text :</FONT></B></TD>
</TR>
</TABLE>
<BR><BR>
<TABLE CELLSPACING="1" CELLPADDING="5" WIDTH="290" ALIGN="LEFT"
BORDER="0" HEIGHT="35">
<TR>
<TD VALIGN="TOP" BGCOLOR="#D4F1B9" WIDTH="278" HEIGHT="33"><INPUT
ID="ExtraText" SIZE="42" MAXLENGTH="60"></TD>
</TR>
</TABLE>
</FORM>
<BR><BR>
<HR>
<FONT COLOR="#FFFFFF">
<FONT FACE="Arial" SIZE="1">
Message content will be:
<BR>
=================================================<BR>
PLEASE CALL REGARDING PROBLEM NO <problem#>:<BR>
=================================================<BR><BR>
<my name> at <my telephone> A.S.A.P.<BR><BR>
<optional extra text><BR>
=================================================<BR>
Thank you.
</FONT></FONT>
<HR>
<P ALIGN="CENTER">
<INPUT TYPE="BUTTON" VALUE=" Send " ONCLICK="BuildMessage">
<INPUT TYPE="BUTTON" VALUE=" Exit " ONCLICK="ExitHTA">
</P>
</BODY>
</HTML>
XXXXXXXXXX
Ha®®y
HarryKrishna.nospam@online.ie