[HELP] Issues with Console Access to Windows VM and Command Execution

Hello everyone,

I am trying to access the console of a Windows VM (deployed on Linux server), execute commands, and retrieve the output. However, I am facing multiple issues:

  1. When I connect to the VM console (via virsh console), the VM outputs a lot of ANSI characters (e.g., [1;1H, [37m). This causes SSHLibrary.Read Until Prompt to fail in capturing the complete command output. To work around this, I use SSHLibrary.Read Until, but unmatched characters from previous outputs sometimes interfere with the next command execution.

  2. After connecting to a Windows VM console, I found that SSHLibrary.Write cannot execute commands, not even simple ones like cls. I also tried using SSHLibrary.Execute Command and OperatingSystem.Run And Return Rc And Output, but none of them seem to work.

Has anyone encountered similar problems? What would be the best approach to ensure stable command execution and output retrieval from a Windows VM console?

Any advice would be greatly appreciated! :smiling_face_with_hearts:

Thanks!

You should use specific options for Open Connection.
Here is an example of my usage:

Open Connection    ${host_under_test}    port=22    width=160    height=80    timeout=90    alias=host    newline=CRLF    prompt=\>    term_type=ansi    escape_ansi=True

Hi Guilherme,

Thank you for your advice.

I followed your suggestion, and encountered some other issues:

Here is robot log:

I really appreciate your help and would love to hear any further insights you might have.

Thanks!

manual logs:

Thanks!

Seems to be a matter of timing.
You enter \n too soon. And test fails because of different prompt.
Increase time and don’t use Read Until Prompt. Use Read and try to confirm the Use any other key to view this channel is in the last line of output.

Hi Helio,

Following your suggestion, change the parameters of open connection:

  • From the log of robot, we can see that cmd was correctly initialized,
  • tried to issue the command ipconfig /all
  • but the cmd closed
  • the keyword failed because the expected prompt did not appear.

Here, the reason of the problem are

  1. The “i” in command “ipcoonfig /all” , and SAC will determine that the ‘i’ symbol to ‘view this channel’.

  2. In the robot log: “The Command Console session is exiting.” I‘ll check why the cmd session exits.

Thank you again for your comments.

Thank you
Xianying