msg command from CMD line (1 Viewer)

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
Hi all,

I want to run the following command from VBA:

If I type "msg * test" into the cmd window, I get a nice Windows message box.

I tried to Shell it like this:

Shell "cmd.exe msg * test" but it does not work. It only brings up the cmd windows but does not execute the msg command.

Any ideas please?

Thanks
 

essaytee

Need a good one-liner.
Local time
Today, 23:19
Joined
Oct 20, 2008
Messages
512
Shell to a batch file, passing in your arguments, just a thought.
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
Thanks I'll try the batch method was just hoping for a more direct way as I'm looping through records and queuing Windows messages boxes for each record matching the criteria.
So I want to limit the time it takes.

PS: I specifically don't want to use msgbox inside Access as I will open the Access database and autorun the above loop and the Quit Access immeditly afterwards
 

isladogs

MVP / VIP
Local time
Today, 14:19
Joined
Jan 14, 2017
Messages
18,240
As an alternative, you could create system tray alerts (AKA balloon tooltips) within Access as these disappear automatically after a few seconds and won't prevent Access closing.
See https://www.access-programmers.co.uk/forums/showthread.php?t=295062

Or you just could have a label whose caption is updated after each loop e.g. step 37 of 250 … as in a progress bar. In fact why not have a progress bar!
 

deletedT

Guest
Local time
Today, 14:19
Joined
Feb 2, 2019
Messages
1,218
Hi all,

I want to run the following command from VBA:

If I type "msg * test" into the cmd window, I get a nice Windows message box.

I tried to Shell it like this:

Shell "cmd.exe msg * test" but it does not work. It only brings up the cmd windows but does not execute the msg command.

Any ideas please?

Thanks

How about this one?

Code:
    Shell "cmd.exe /K  msg * test"
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
Thanks but I very specifically want to open, run code and quit Access without any User input etc.
So I don't want to keep Access open.
If I create Windows message boxes it automatically opens one after the other as you close them.
Which means I can que them and the User will see them at a later stage when they get to their PCs.
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
@Tera - Thanks. I'm not at the office for a few hours. Will test later
 

isladogs

MVP / VIP
Local time
Today, 14:19
Joined
Jan 14, 2017
Messages
18,240
Fair enough.
Just one other alternative to consider which I use with automatic updates that run overnight as scheduled tasks. In other words no user interaction.
You can get Access to create a standard text log file and add entries after each event.
You can if you wish open that log file so it is visible when the user returns ...or automatically email it to the user as an attachment
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
Ahh - I found the answer:

Code:
start "" cmd /c "echo Hello world!&echo(&pause"

So I implemented it like this:

Dim strMsg As String
strMsg = "Test"
Shell "cmd /c echo " & strMsg & " &echo(&pause", vbNormalFocus

Does the trick
Cheers!
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:19
Joined
Sep 21, 2011
Messages
14,320
shell "msg * test" works for me?
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
shell "msg * test" works for me?

Even without referring to cmd.exe - I mean did you put the above code in a module and it opens a Windows Msgbox just like that?
If so what Win version are you running?
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:19
Joined
Sep 21, 2011
Messages
14,320
I just executed it from the immediate window?
Win 10 Pro, Access 2007
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
I just executed it from the immediate window?
Win 10 Pro, Access 2007

I get a "file not found" which makes sense since the Shell command would be looking for "msg". I'm running Win 7 so I cannot comment on Win 10 but we are running same Access 2007 so I still find it a bit weird that yours are working. Strange hey
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:19
Joined
Sep 21, 2011
Messages
14,320
Hmm, not something I have used previously, but it appears to work in Win7 :confused:

Also works like that in a command window, which is why I tried that format.

https://www.winsentmessenger.com/msg/

From that link

The user must have Message special access permission to send a message.

No idea what they may be though.
 

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
On my side it works in the Cmd window yes but not inside Access in any way.
I still find this strange.
No words at this moment...see screenshot in case you spot something
 

Attachments

  • Screenshot_1.jpg
    Screenshot_1.jpg
    13.6 KB · Views: 98

isladogs

MVP / VIP
Local time
Today, 14:19
Joined
Jan 14, 2017
Messages
18,240
Using Win10, A2010

Shell "msg * test" produces a popup window.

Shell "cmd /c echo " & strMsg & "&pause", vbNormalFocus creates a command window message

In each case, doing so repeatedly creates another window each time.
Clicking OK will allow users to view each message in turn

BUT do you really want users to have to click through 20 or 50 or whatever messages each time they return. Do you really think they will read each one?

It was for that reason I suggested saving each message to a log file
Attached is an example - in this case a log file created during a version update but the idea works for any situation
Just one file to read and as I said it can be left open on the desktop or emailed as preferred
 

Attachments

  • VersionUpdateLog.txt
    816 bytes · Views: 76

Gasman

Enthusiastic Amateur
Local time
Today, 14:19
Joined
Sep 21, 2011
Messages
14,320
My system is only 32bit.
my msg.exe is in Windows\System32

That is in my paths

Code:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;C:\Program Files\ZyXEL PLA Series Utility\ZyXEL PLA Series Utility\cml;C:\Program Files\Skype\Phone\;C:\WINDOWS\System32\OpenSSH\;C:\Users\Paul\AppData\Local\Microsoft\WindowsApps;C:\Program Files\ZyXEL PLA Series Utility\ZyXEL PLA Series Utility\cml;

 

Attachments

  • msg.png
    msg.png
    25.4 KB · Views: 648

Freshman

Registered User.
Local time
Today, 16:19
Joined
May 21, 2010
Messages
437
BUT do you really want users to have to click through 20 or 50 or whatever messages each time they return. Do you really think they will read each one?

Yes that is what the Client wants. This is Birthday reminders so it might be 1 or 2 messages per week - so VERY low traffic. But they want to see it like that instead of having to go into or log into any system.
At the same time the messages are triggered a separate SMS is also going to the specific person. But the popups will be for the Admin person

PS: So you guys are not getting the "file not found" error I'm getting inside Access?
 

Users who are viewing this thread

Top Bottom