LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: Using "msg" command with "System Exec.vi"

Solved!
Go to solution

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?

- Mike
~~~~~~~~~~~~~~
Current Setup:
LabView 2010
Windows 7
0 Kudos
Message 1 of 19
(4,794 Views)

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

 

 

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 19
(4,768 Views)

-> 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.

- Mike
~~~~~~~~~~~~~~
Current Setup:
LabView 2010
Windows 7
0 Kudos
Message 3 of 19
(4,764 Views)

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

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 19
(4,749 Views)

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.

 

- Mike
~~~~~~~~~~~~~~
Current Setup:
LabView 2010
Windows 7
0 Kudos
Message 5 of 19
(4,744 Views)

I was not able to reproduce this error on my machine. Is there any difference in your code from something simple like this?

system exec.JPG

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 6 of 19
(4,731 Views)

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%"

 

 

 

- Mike
~~~~~~~~~~~~~~
Current Setup:
LabView 2010
Windows 7
0 Kudos
Message 7 of 19
(4,727 Views)

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

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 8 of 19
(4,724 Views)

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.

- Mike
~~~~~~~~~~~~~~
Current Setup:
LabView 2010
Windows 7
0 Kudos
Message 9 of 19
(4,713 Views)

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

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 10 of 19
(4,702 Views)