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.Shell")
strUser = "wilbur.smith"
strMessage = "Hello"
'Check to see if the file is available
If Dir("r:\!a\abc123.txt") <> "" Then
'File not found
'objShell.Run ("cmd /k c:\windows\system32\msg.exe * /server:" & strUser & " " & strMessage)
'objShell.Run ("runas /user:domain\UserName ""C:\Windows\System32\cmd.exe /k C:\windows\system32\msg.exe * /server:" & strUser & " " & strMessage & """")
'objShell.Run ("cmd /c c:\pstools\psexec -u domain\username -p Password cmd /c msg * /server:" & strUser & " " & strMessage)