The following line works fine from my java application on Windows XP:
Process p = Runtime.getRuntime().exec("msg.exe * this is a test");
When it executes on Windows 7 (64-bit), I get the following error:
Cannot run program "msg.exe": CreateProcess error=2, The system cannot find the file specified
I have tried putting in the full path to the .exe, and I get the same error:
Process p = Runtime.getRuntime().exec("c:\\Windows\\System32\\msg.exe * this is a test");
Using ProcessBuilder instead of Runtime gives the same error:
Process p = new ProcessBuilder("msg.exe * this is a test").start();
I tried to rule out a permissions issue by temporarily giving everyone full control to msg.exe but Windows would not let me - the options were greyed out even when I logged in as administrator.
So I confirmed that the user of the java process has read and execute permissions to msg.exe.
I am able to successfully run the command (as the same user of the java process) from the command line of the Windows 7 machine.
In the notes of this post: C# cannot find file specified, someone alludes to a similar issue with a Windows 64-bit machine not finding msg.exe from a C# program, so perhaps there is something on the Windows configuration side that I need to do?
Is there a way to get a java application to send a network message on Windows 7? Or some alternative for sending a network message that will work?