Call Shell

doulostheou

Registered User.
Local time
Today, 04:41
Joined
Feb 8, 2002
Messages
314
I am working on a function that uses the net send command in Dos to send out a message to our unit. It works fine, but in DOS there is no way to send the message to a selected group of users. There are around 70 computers that I want to be able to send a message to without using net send * to send it to the whole network domain. So I used a loop:

Call Shell("net send " & NetName & " " & Message)

This works, but it opens a dos window for each of the 70 computers (not very efficient). This is especially inefficient since when a computer is turned off, there is a stall while dos determines they are not there. I can think of two solution, but I don't know how to go about either of them.

1) Is there a way to continue to use one dos window to send the message repeatedly?

2) If not, can I somehow slow down the code so it will finish working with one Dos window before looping and starting a new one.
 
I would create a .bat file, write all the net send commands to this file, then use Shell to run the bat file.
 
Thank you. This is actually exactly what I ended up doing. I create the batch file through code and it sends the message to the specefied computers. The only hitch is that the batch file takes a long time to run. If the computer is not turned on, it hangs for about 3 seconds before going to the next one. With 150 computers, this can really make it a long process. The final product was that we only use it for situations that are not emergencies. If anyone is interested in the code that writes the batch on the fly, it is posted below (Message is a field on the form that they type in before they click the button to execute this).

Code:
        Dim DB As Database
        Dim RST As Recordset
        Dim Str As String

        DoCmd.Hourglass True
        Open "T:/Sups Only/IAT staff/NetSend.bat" For Output As #1
        Print #1, "cd \"
        Set DB = CurrentDb
        Set RST = DB.OpenRecordset("NetNames")
        With RST
        .MoveFirst
        Do Until RST.EOF
        Str = "net send " & .Fields("NetName") & " " & Message
        Print #1, Str
        .MoveNext
        Loop
        End With
        Set RST = Nothing
        Set DB = Nothing
        Close #1
 
If you use windowstyle 6 in your shell statement - minimised & no focus, does this let Access get on with life while DOS churns away in the background, or does the Access code still wait until the batch file finishes executing?
 
I can go on with life while the batch file runs. The only issue is that the message itself takes so long to get to everyone. If we have something that we need everyone to know immediately, it just won't work.
 

Users who are viewing this thread

Back
Top Bottom