# How to do a dynamic Desktop path on Windows and Linux?

**URL:** <https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [September 4, 2025, 10:35am UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371 "2025-09-04T10:35:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [September 4, 2025, 10:35am UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/1 "2025-09-04T10:35:33Z")

</div>

I have this line:

```python
system.file.openFile("xlsx", "C:\Users\name\Desktop")

```

However some of my team works on Linux and that path doesn't work.  
How could I do a dynamic Desktop path?

I tried:

```python
import os
os.environ['USERPROFILE'] + '\Desktop'

```

But for some reason for some of us doesn't work (?). It opens in documents sometimes. Not sure.

Thank you!

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [September 4, 2025, 12:27pm UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/2 "2025-09-04T12:27:01Z")

</div>

I believe `$HOME` (or `~` for short) works on most distros of Linux and Windows.

[Wiki: Home\_directory](https://en.wikipedia.org/wiki/Home_directory#Location)

The below should expand to the appropriate user location in both OS:

```python
import os.path
relativePath = "~/Desktop" # Linux, Windows
userPath = os.path.expanduser(relativePath)
print userPath

```

I’m unaware if the `/Desktop` portion breaks down on certain distros.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 4, 2025, 12:42pm UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/3 "2025-09-04T12:42:56Z")

</div>

Don't use jython stdlib. Use `java.io.File` or `java.nio.file.Path` to construct your absolute file names. These will properly use the appropriate platform folder separator. Use those classes to parse the string from `java.lang.System.getEnv("HOME")` as your starting point.

Also, be aware that using backslashes as folder separators **only** works on Windows. In java and jython, forward slashes usually work in all OSes.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [September 4, 2025, 1:00pm UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/4 "2025-09-04T13:00:07Z")

</div>

Thanks! But I don't seem able to make it work on all enviroments. I changed the way it's getting done so I don't trully need it anymore.

Thx anyway! I trully appreciate it

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 4, 2025, 1:02pm UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/5 "2025-09-04T13:02:13Z")

</div>

You didn't tag your post as Vision, but it only applies to Vision. I hope you weren't expecting any of this to work in Perspective.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [September 4, 2025, 2:01pm UTC](https://forum.inductiveautomation.com/t/how-to-do-a-dynamic-desktop-path-on-windows-and-linux/110371/6 "2025-09-04T14:01:11Z")

</div>

Not vision, not perspective. Script meant to execute from the designer only.
