04-14-2011 02:29 PM
I'm attempting to write some LabView code that takes advantage of the "System Exec.vi". At the moment, I've tried using it to ping machines, return the ipconfig and run through the example code that NI provides.
I would like to use the "msg" command used on Windows operating systems to send out a message to multiple machines on our network at once. Warning them we're about to update a program and they should log-off, things like that.
I tried using the "msg" command in LabView keeps returning errors. I also wrote a quick batch file as follows:
@echo on
cd c:\Windows\System32\
msg.exe /server:localhost * test
When I launch the batch from windows, it executes. When I launch it from LabView (using the System Exec.vi) it fails.
Potential Quirks:
I discovered in a different location that in order for a machine to receive these messages they need to have a registry entry in:
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" and have a DWord called "AllowRemoteRPC" = 1.
Note that "/server:localhost" could be "/server:anycomputer" and the " * " is used as a wildcard which sends a message to anyone who is logged onto that machine. Also note that "test" is the message to be sent.
Any ideas why I'm having a problem?
tl;dr: "System Exec.vi" won't run the "msg" command. Why is this?
Solved! Go to Solution.
04-18-2011 09:34 AM
Mike,
What versions of labview and windows are you on? Have you ever sent any commands out, or is msg the only one you've tried so far?
Do you have any firewalls or virus scans up? They may pick up labview, but not your command prompt.
Finally, in tools>>options, you may need to change your access settings under VIserver and Webserver.
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments
04-18-2011 01:37 PM
-> What versions of labview and windows are you on?
LabView 2010 and Windows 7.
-> Have you ever sent any commands out, or is msg the only one you've tried so far?
I've successfully used the 'ping' command and also returned a standard 'help' command to LabView.
-> Finally, in tools>>options, you may need to change your access settings under VIserver and Webserver.
My VI server settings are allowing everything except "Show VI Scripting Functions, properties and methods"
I have nothing configured for a web server, since I didn't plan on using it for this. Unless it has some sort of connection that I am missing.
I'm attempting a work-around where LabView will generate a batch file to run from the desktop instead, since it seems that something is getting lost in translation between LabView and the command-prompt.
04-19-2011 11:59 AM
Mike,
One thing you may want to check really quick is the msg command input string. Right click on it and select " '\' code display " to make sure there are no spurrious characters in the string causing the command to not be sent properly.
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments
04-19-2011 01:23 PM
Command Line Input of: cmd /c msg /server:localhost * test
Returns a standard error of: 'msg' is not recognized as an internal or external command,
operable program or batch file.
In the Windows 7 command prompt, that command will pop-up a dialog on the screen that reads: "test".
In 'codes' mode, it shows the spaces I typed in as "\s" codes, which was expected.No other codes appeared in the control.
For reference, the command: cmd /c ping localhost
Works without issue.
04-20-2011 11:50 AM
I was not able to reproduce this error on my machine. Is there any difference in your code from something simple like this?
04-20-2011 02:02 PM
Nope, when I run that code I end up with:
Return Code: 1
Standard Error: 'msg' is not recognized as an internal or external command, operable program or batch file.
However; the batch file below does work for me when launched through Windows Explorer:
@echo off cd c:\Windows\System32\ SET MessageToSend=test msg.exe /server:localhost * "%MessageToSend%"
04-20-2011 02:30 PM
Mike,
Are you an administrator on your machine? And do you have any virus protection or firewalls which may prevent you from accessing your system32 folder?
Sounds like it may be a permissions issue.
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments
04-21-2011 06:56 AM
Yup, I am an administrator.
However, considering the batch file runs in windows, something must be getting lost in translation between where the command is being pushed through to the command line.
04-21-2011 02:23 PM
Mike,
This is extremely bizzarre behavior, but we have another thing or two we can try:
on the single-block program I posted before, try
cmd /c C:\Windows\System32\msg.exe /server:localhost * test
as the string. Its possible that for some unknown reason, it isn't referencing the msg command to the proper location (which would be surprising if you can run ping.exe which is in the same directory).
Also try just typing
msg /server:localhost * test
into a command prompt, without any of the cd or anything.
Let me know how that goes for you.
Regards,
Kyle Mozdzyn
Applications Engineering
National Instruments