This is a pretty common question on the VixCOM forum: How do I run a command in the virtual machine and collect its output?
VixCOM doesn’t have any support for this, so is there something we can do about it? I want to have a RunCommandInGuest to execute shell and other commands that returns StdOut and StdErr. So this is what I want to write:
I figured that the easiest way would be to pipe output to a file and collect that file. Because the commands can also contain piping, we have to create a temporary .bat that contains the command. I did it for Windows, so you get Vestris.VMWareLib.Tools.Windows.Shell.RunCommandInGuest in VMWareTasks.