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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Arguments with Shell() command

Status
Not open for further replies.

jpastika

MIS
Jan 30, 2002
10
US
I am trying to create a pop-up alert system inside Access using the Shell() command to execute a .CMD file. What I want is to be able to execute the .CMD file and pass it the computer name of the person I want the pop-up message to go to. I would also like to be able to pass the actual text of the pop-up message to the .CMD file. According to Access' help, you can pass arguments using the Shell() command, but I don't know the correct syntax. Also, what is the syntax to use inside of the .CMD file for receiving the passed arguments?

Here is the code I have behind the button that calls the Shell command:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stAppName As String

stAppName = "C:\message_test.cmd /USER=jpastika"
Call Shell(stAppName, 0)

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub


***************************************

Here is what I have in my .CMD file:

net send %COMPNAME% %MESSAGE

****************************************


Any help or suggestions would be greatly appreciated! Thank you.

-Jeremy Pastika
 
From the documentation I have read on the Shell() command has said that anything you can do as a DOS command you can do with this. Meaning...can you setup your stAppName string to contain the requuired parameters for the .CMD file? If so it would only be a matter of adding to the stAppName string.

HTH
Ken ::)
 
Thank you for your response Ken. I don't know what I was thinking by going through the trouble of executing a .CMD file and trying to pass it arguments when all I had to do was call the "NET SEND" command directly from the "Shell()" command. Here's what I am using now:

***************************

stAppName = "NET SEND "& Me!COMPNAME &" "& Me!MESSAGE
Call Shell(stAppName, 0)

****************************

Where COMPNAME and MESSAGE are fields on the form that the command button that triggers the Shell() command resides on

This seems to work great! Again thank you for your fast response.

-Jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top