# Run exe in windows container using python

**URL:** <https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843>\
**Category:** General\
**Created:** [August 15, 2021, 6:35am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843 "2021-08-15T06:35:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![princyvictor](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@princyvictor](https://forums.docker.com/u/princyvictor)\
**Post date:** [August 15, 2021, 6:35am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/1 "2021-08-15T06:35:45Z")

</div>

Hi,

I am working on executing an exe file (notepad.exe) inside windows container using python.

I have copied these in my container:

- exe file

- dockerfile that calls python script

- python script that runs exe

When I build and run these, Its not showing any error. But, the exe is also not running. Am I doing anything wrong? Can notepad.exe open in host machine or do I have to check the processlist in container to check whether it is running or not?

---

<div class="post-metadata">

**Author:** ![shomrai](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/shomrai/32/33023_2.png) [@shomrai](https://forums.docker.com/u/shomrai)\
**Post date:** [August 15, 2021, 9:58am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/2 "2021-08-15T09:58:05Z")

</div>

It would be easier to help if you’d share the details of your build & run and how did You conclude that the exe is not running?

---

<div class="post-metadata">

**Author:** ![princyvictor](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@princyvictor](https://forums.docker.com/u/princyvictor)\
**Post date:** [August 15, 2021, 10:05am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/3 "2021-08-15T10:05:18Z")

</div>

![docker run & build](https://global.discourse-cdn.com/docker/original/3X/f/1/f1200b641c13e5bc6ab2511189b42b730b52d1f1.png)

I have attached the screenshot of run & build.

This is the python code I am executing.

import os  
print(“working”)  
os.startfile(“notepad.exe”)  
print(“successful”)

As notepad is not opening, I thought that it is not executing. Actually, I want to execute an exe file and take the memory dump of Windows container. Can you please tell me what to do for getting the memory dump? Also,how will I know that the exe is executing or not?

---

<div class="post-metadata">

**Author:** ![shomrai](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/shomrai/32/33023_2.png) [@shomrai](https://forums.docker.com/u/shomrai)\
**Post date:** [August 15, 2021, 10:43am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/4 "2021-08-15T10:43:52Z")

</div>

Make sure you have notepad.exe in Your Win container, and specify full path like os.startfile(“C:\windows\system32\notepad.exe”)  
If there isn’t copy to the image.

---

<div class="post-metadata">

**Author:** ![princyvictor](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@princyvictor](https://forums.docker.com/u/princyvictor)\
**Post date:** [August 15, 2021, 10:49am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/5 "2021-08-15T10:49:35Z")

</div>

The exe, python file and docker file are inside the container as well. I have mounted my E:\input\ path to the container C:\data.

---

<div class="post-metadata">

**Author:** ![shomrai](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/shomrai/32/33023_2.png) [@shomrai](https://forums.docker.com/u/shomrai)\
**Post date:** [August 15, 2021, 10:58am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/6 "2021-08-15T10:58:14Z")

</div>

Did you try `os.startfile("<path to exe>\notepad.exe")` ?

---

<div class="post-metadata">

**Author:** ![shomrai](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/shomrai/32/33023_2.png) [@shomrai](https://forums.docker.com/u/shomrai)\
**Post date:** [August 15, 2021, 11:01am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/7 "2021-08-15T11:01:15Z")

</div>

this part was cut out so i repeat : os.startfile("\path-to-the-exe\notepad.exe")

---

<div class="post-metadata">

**Author:** ![princyvictor](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@princyvictor](https://forums.docker.com/u/princyvictor)\
**Post date:** [August 15, 2021, 11:20am UTC](https://forums.docker.com/t/run-exe-in-windows-container-using-python/113843/8 "2021-08-15T11:20:22Z")

</div>

Yes. But, its showing the error **FileNotFoundError: [WinError 2] The system cannot find the file specified:**

I am executing the docker commands in the powershell and the path is set as **E:\input\Automation** (as shown in the above screenshot). That path has all files. So, is it mandatory to give the full path? When I don’t give any path, it’s not showing any error.
