If we have a headless test server running sikuli (both ubuntu and windows configurations needed), how to get it work without a physical monitor and preferably for as many screen resolutions as possible.
4 Answers
I successfully got sikuli running in headless mode (no physical monitor connected)
Ubuntu: check Xvfb.
Windows: install display driver on the machine (to be headless) from virtualbox guest additions display drivers and use TightVNC to remotely set resolution from another machine.
Detailed steps for windows 7
Assume that:
- Machine A: to be headless machine, windows 7, with vnc server ready (e.g. TightVNC server installed and waiting for connections).
- Machine B: will be used to remotely setup the virtual display driver on machine A.
steps:
- Download virtualbox guest additions iso file on Machine A from here (for latest version check latest version here and download VBoxGuestAdditions_x.y.z.iso)
- Extract iso file (possibly with winrar) into a directory (let us call it folder D)
- using command prompt cd to D folder
Driver extraction
-To extract the 32-bit drivers to "C:\Drivers", do the following:
- VBoxWindowsAdditions-x86 /extract /D=C:\Drivers
-For the 64-bit drivers:
- VBoxWindowsAdditions-amd64 /extract /D=C:\Drivers
Goto device manager
add hardware
Restart and connect with VNC viewer, now you should be able to change screen resolution
other valuable info on launchpad.

- 2,937
- 5
- 36
- 56
-
1I successfully got it running as well but the images that sikuli used to work with to find a region of the screen don't work as before anymore. I will need more time to play around and understand the reason/pattern behind it but so far some of the images seem to be working and some are not! Any thoughts? If I will need to retake images for this particular headless node, what should I take into consideration? While I'm at it, do I need to keep the VNC session alive for the remote code to work or the fact that VNC server is listening to connections in background is enough? – Saba Ahang Dec 07 '14 at 22:20
-
1No need for VNC connection to keep alive while code is running on the virtual machine, make sure when taking screen shots that your windows color theme is windwos 7 basic (I found it should be identical to the virtual machine windows colors), otherwise you may decrease Sikuli similarity (which i don't recommend as it could lead to false pass). – Amr Lotfy Dec 08 '14 at 06:17
-
1Thank you so much! This works perfectly on windows server 2016 on AWS EC2! – DaxChen May 27 '17 at 05:47
-
@DaxChen You are most welcome, I am glad I could help :) – Amr Lotfy May 27 '17 at 16:06
-
1@AmrLotfy do you have any suggestion how your above solutin work in window 10 (aws) – bipin Apr 08 '20 at 12:38
-
@AmrLotfy how to achieve this but in Windows 10? – JustToKnow Aug 06 '23 at 18:44
I got SikuliX working in a true headless mode in GCE with a Windows 2016 client system. It takes some duct tape and other Rube Goldberg contraptions to work, but it can be done.
The issue is that, for GCE (and probably AWS and other cloud environment Windows clients), you don't have a virtual video adapter and display, so, unless there's an open RDP connection to the client, it doesn't have a screen, and SikuliX/OpenCV will get a 1024x768 black desktop, and fail.
So, the question is, how to create an RDP connection without having an actual screen anywhere. I did this using Xvfb (X Windows virtual frame buffer). This does require a second VM, though. Xvfb runs on Linux. The other piece of the puzzle is xfreerdp 2.0. The 2.x version is required for compatibility with recent versions of Windows. 1.x is included with some Linux distros; 2.x may need to be built from sources, depending on what flavor Linux you're using. I'm using CentOS, which did require me to build my own.
The commands to establish the headless RDP session, once the pieces are in place, look something like this:
/usr/bin/Xvfb :0 -screen 0 1920x1080x24 &
export DISPLAY=:0.0
/usr/local/bin/xfreerdp /size:1920x1080 /u:[WindowsUser] /p:"[WindowsPassword]" /v:[WindowsTarget]
In our environment we automated this as part of the build job kicked off by Jenkins. For this to work under the Jenkins slave, it was also necessary to run the Jenkins slave as a user process, rather than a service... this can be accomplished by enabling auto admin login and setting the slave launch script as a run (on logon) command.

- 51
- 3
For those looking to automate on ec2 windows machines, this worked for me: http://www.allianceglobalservices.com/blog/executing-automation-suite-on-disconnectedlocked-machines
In summary, I used RDC to connect, put the following code in a batch file on remote desktop, double clicked it, and sikulix started working remotely (kicking me out of RDC at the same time). Note that ec2 windows machines default to 1024x768 when tscon takes over which may be too small so TightVnc can be used to increase the resolution to 1280x1024 before running.
tscon.exe 0 /dest:console
tscon.exe 1 /dest:console
tscon.exe 2 /dest:console
tscon.exe 3 /dest:console
START /DC:\Sikulix /WAIT /B C:\Sikulix\runsikulix.cmd -d 3 -r C:\test.sikuli -f C:\Sikulix\log.txt -d C:\Sikulix\userlog.txt

- 1,784
- 19
- 25
-
HI Adam, I am using SIKULIX as maven dependency not on ec2 . The slave is windows 7 machine. – Sunny Sachdeva Mar 17 '16 at 10:48
-
2the link is offline now, but you can use http://web.archive.org/web/20150607234258/http://www.allianceglobalservices.com/blog/executing-automation-suite-on-disconnectedlocked-machines – Manuel M Nov 29 '16 at 11:56
I just figure out a way to resolve similar issue.
My env:
local: windows pc
remote (for running sikulix + app I would like to test): windows ec2 instance
My way:
1.create a .bat file, its contents:
ping 127.0.0.1 -n 15 > nul
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
cd "\path\to\sikulix"
java -jar sikulixide-2.0.5.jar -r /path/to/sikulix -c > logfile.log
- prepare your app
- run the bat (right click > run as administrator)
ping
will give your 10s, so that you can bring your app back to front- you will be disconnnected from rdp connection
Explanation:
ping
is like "sleep"for
loop: kick out current user & keep session alive

- 706
- 10
- 24
-
This works great. But this is locking me out and not able to Remote into the machine again. How do I stop that? Probably control the for loop will help. – Vinay Feb 28 '23 at 10:36
-
@Vinay, "this is locking me out and not able to Remote into the machine again" I think it's caused by other issues, the script above only starts your sikuli script & kick you out, nothing more, you should be able to reconnect the remote desktop with rdp – simomo Mar 01 '23 at 20:32
-
thanks. Yes it was locking me out as I am using this to connect to vpn and the ip changes once connected – Vinay Mar 25 '23 at 03:16