Since the answer to this would be of use to any MBS user on Windows, I want to ask @Christian Schmitz for clarification of the difference between these two classes and how they should be used. As a starting point, I use this code in a Window PushButton’s Action Event:
[code]// Dim tShell As New ShellMBS
Dim tShell As New WindowsProcessMBS
// Simplest form of the WindowsProcessMBS way -
tShell.CommandLine = “cmd /c mtx -f \\.\changer0 status”
If tShell.Run Then
Window1.TextArea1.AppendText tShell.ReadOutput(tShell.AvailableBytesOutput)
Else
Window1.TextArea1.AppendText tShell.ReadError(tShell.AvailableBytesError)
End If
Do
Window1.TextArea1.AppendText tShell.ReadOutput(tShell.AvailableBytesOutput)
Loop Until Not tShell.Running
[/code]
However, when I run this, a back end process is kicked off that never returns, the False leg of the initial If block is fired, but I get no output in either Output or Error and results in the need to reboot the system to clear that process.
I’m obviously missing the point somewhere. So, what did I miss?
[quote=437265:@Christian Schmitz]So run method returns false?
I wonder whether you may need to provide full app path as there is no cmd to evaluate PATH environment variable.[/quote]
Yes - Rebooting to try that.
Same result - The call to tShell.Run results in False immediately, but the process that was launched never exits. However, I can now “End Task” it and not reboot to clear it.
When using ShellMBS, I don’t get the hung background process, but still no output and the call to .Execute returns immediately with %ERRORLEVEL% == 2. The other change is that even though the exe being called, I’m not being prompted to authroize the run (it’s set to “Run as administrator”) like I am in the WindowsProcessMBS call of the same command.