rodneygray
asked on
Send message to specific user from Access Database
I have a database named AutoUpdate. The function is to pull data from a standalone database on a remote pc. If for some reason the routine to pull the data cannot run (network is down), I want the program to alert specific user(s) to the problem. I am trying to use msg.exe to accomplish this task. So far, I have not been able to do so. I have tried using Shell and pstools psexec to accomplish task.
Below is code I have tried so far.
The first code does not run because there is not a password.
The second code asks for a password. When password is entered, a second command prompt opens, code ends, no message.
The third line of code appears to work. However, I get two cmd windows. The first tells me than I am running "Execute Procedures remotely. The second is just blank.
Dim strUser, strMessage As String
Dim objShell As Object
Set objShell = CreateObject("WScript.Shel l")
strUser = "wilbur.smith"
strMessage = "Hello"
'Check to see if the file is available
If Dir("r:\!a\abc123.txt") <> "" Then
Else
'File not found
'objShell.Run ("cmd /k c:\windows\system32\msg.ex e * /server:" & strUser & " " & strMessage)
'objShell.Run ("runas /user:domain\UserName ""C:\Windows\System32\cmd. exe /k C:\windows\system32\msg.ex e * /server:" & strUser & " " & strMessage & """")
'objShell.Run ("cmd /c c:\pstools\psexec -u domain\username -p Password cmd /c msg * /server:" & strUser & " " & strMessage)
End If
Below is code I have tried so far.
The first code does not run because there is not a password.
The second code asks for a password. When password is entered, a second command prompt opens, code ends, no message.
The third line of code appears to work. However, I get two cmd windows. The first tells me than I am running "Execute Procedures remotely. The second is just blank.
Dim strUser, strMessage As String
Dim objShell As Object
Set objShell = CreateObject("WScript.Shel
strUser = "wilbur.smith"
strMessage = "Hello"
'Check to see if the file is available
If Dir("r:\!a\abc123.txt") <> "" Then
Else
'File not found
'objShell.Run ("cmd /k c:\windows\system32\msg.ex
'objShell.Run ("runas /user:domain\UserName ""C:\Windows\System32\cmd.
'objShell.Run ("cmd /c c:\pstools\psexec -u domain\username -p Password cmd /c msg * /server:" & strUser & " " & strMessage)
End If
How should that work when the network is down? Then the message cannot arrive and the user thinks everything it's fine.
You need to post always a message. So that no message means: Oops. Network issues.
You need to post always a message. So that no message means: Oops. Network issues.
If the network is down then how can you send a message over the network?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
strongly recommend against trying to use Access across a wireless network. Access is very temperamental with respect to the connection between the Front End and the Back End and wireless networks do not provide consistent, persistent connections. You will inevitably have problems with lost connections and database corruption if you persist with this technique.
ASKER
Did not receive any other solutions and this one works.
Dale