Wrapping a Script In VB

B

Barney

I may be posing to the wrong group but I have a lot of
faith in you lot.

I've written the following little script that works like a
charm:

@ECHO OFF
COLOR 1F
TITLE Instant Messenger
CLS
ECHO/
SET /P Recipient=Type the computer name or user name:
CLS
ECHO/
SET /P Message=Type your message:
CLS
NET SEND %Recipient% %Message% 1>NUL 2>NUL || NET SEND %
ComputerName% ERROR: %Recipient% could not be found on the
network. 1>NUL 2>NUL
EXIT


I've also written a VB front end to provide a graphical
interface. It contains the following code

Shell "NET SEND /DOMAIN:" & txtRecipient.Text & " " &
txtMessage.Text

where txtRecipient.Text and txtMessage.Text are the
contents of two text boxes.

My problem is: I would like to add the error checking that
the script provides with the

|| NET SEND %ComputerName% ERROR: %Recipient% could not be
found on the network. 1>NUL 2>NUL


code.

How do I do this with the VB Shell command?
 
B

Bill Stewart

Barney said:
I may be posing to the wrong group but I have a lot of faith in you lot.

I've written the following little script that works like a charm:

@ECHO OFF
COLOR 1F
TITLE Instant Messenger
CLS
ECHO/
SET /P Recipient=Type the computer name or user name:
CLS
ECHO/
SET /P Message=Type your message:
CLS
NET SEND %Recipient% %Message% 1>NUL 2>NUL || NET SEND %ComputerName%
ERROR: %Recipient% could not be found on the network. 1>NUL 2>NUL
EXIT

I've also written a VB front end to provide a graphical interface. It
contains the following code

Shell "NET SEND /DOMAIN:" & txtRecipient.Text & " " & txtMessage.Text

where txtRecipient.Text and txtMessage.Text are the contents of two text
boxes.

My problem is: I would like to add the error checking that the script
provides with the

NET SEND %ComputerName% ERROR: %Recipient% could not be found on the
network. 1>NUL 2>NUL

code.

How do I do this with the VB Shell command?

Hi Barney,

You're right -- this isn't really the place for a VB question, but here's a
stab at it.

Instead of using the VB runtime Shell command, you could add the Windows
Script Host Object Model (wshom.ocx) to your project, and create a WshShell
object. Then you can access the exit code of the NET SEND command for use
in your code. For example:

Dim lngRC As Long
Dim objWshShell = New WshShell
lngRC = objWshShell.Run(objWshShell.ExpandEnvironmentStrings("%SystemRoot%
\system32\net.exe send /domain:mydomain ""Message""", 0, True)

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top