Using Symbolic Links to Redirect ProgramData Files and Folder for VDI Environments


Using Symbolic Links to Redirect ProgramData Files and Folder for VDI Environments


During a VDI deployment with VMware Horizon, I discovered that one of the applications in the environment was saving important user information inside the ProgramData folder. Even though the end-user was utilizing persistent disks, the ProgramData folder by default gets saved on the C-drive and would be cleared of any user-specific when utilizing a refresh or recompose.

Typically in a scenario like that it is normally to discuss adjusting licensing to VMware Horizon Enterprise edition or utilizing desktop virtualization management software developed by companies such as Liquidware Labs However, since there was only one problematic application in the environment and there were budgetary constraints, the end-user wanted to explore a more creative and budgeted solution. The solution was to for this case was to utilize symbolic links.


Understanding Symbolic Links

First, it is important to note that symbolic links (sometimes referred to as soft links) can be absolute symbolic links or relative symbolic links. Additionally, there are also hard links.

A great bullet point explanation of the two pulled from the following link has been provided below

Hard links:

  • indistinguishable from other directory entries, because every directory entry is hard link
  • “original” can be moved or deleted without breaking other hard links to the same inode
  • only possible within the same filesystem
  • permissions must be the same as those on the “original” (permissions are stored in the inode, not the directory entry)
  • can only be made to files, not directories

Symbolic links (soft links)

  • simply records that point to another file path. (ls -l will show what path a symlink points to)
  • will break if original is moved or deleted. (In some cases it is actually desirable for a link to point to whatever file currently occupies a particular location)
  • can point to a file in a different filesystem
  • can point to a directory
  • on some file system formats, it is possible for the symlink to have different permissions than the file it points to (this is uncommon)

Additionally, an example showing the difference between an Absolute Symbolic Link and Relative Symbolic Link pulled from the following forum post has been displayed below:


Example 1: Absolute Symlink

/some-folder/absolute-symlink -> /target-folder/file.txtresolves to/target-folder/file.txt

If you move this symlink to some other folder, this doesn’t affect the resolved path:

/some-other-folder/absolute-symlink -> /target-folder/file.txtstill resolves to/target-folder/file.txt


Example 2: Relative Symlink

/some-folder/relative-symlink -> target-folder/file.txtresolves to/some-folder/target-folder/file.txt

If you move this symlink to some other folder, the resolved path will change accordingly:

/some-other-folder/relative-symlink -> target-folder/file.txtnow resolves to/some-other-folder/target-folder/file.txt


Note: Some applications do not support symbolic links and some applications require a hard link. It is important to test functionality after creating a symbolic link.

Creating a Symbolic Link

For creating a Symbolic Link, our syntax will be (screenshot shown below of help menu): 

mklink [[/d] | [/h] | [/j]]


Symbolic Link to Local Drive

In the example below, I am making a symbolic link for a file called test.txt.

Source File: C:ProgramDatasymboliclink-oldlocationtest.txt
Destination File: D:symboliclink-oldlocationtest.txt

Before creating the symbolic link make sure that text.txt file has been moved from the old location to the new location. If this action is not performed, an error will appear stating “cannot create a file when that file already exists” If the file is created successfully, a confirmation message will appear.

mklink “C:ProgramDatasymboliclink-oldlocationtest.txt“ “D:symboliclink-oldlocationtest.txt”

If a directory search is performed, the file will now display as a SYMLINK.

Symbolic Link to a SMB Share

Similar to the Symbolic Link to Local Drive, make sure that the file or folder already exists in the new location before creating the link. When creating a symbolic link to a SMB or CIFS share, the mapped drive or the SMB share can be utilized. Both examples have been shown below. Similar to the previous example, a directory search will display the SYMLINK.

Source File: C:ProgramDatasymboliclink-oldlocationsmb-old.txt
Destination File: P:smb-new.txt OR cifs-shareSMB-new.txt

mklink "C:ProgramDatasymboliclink-oldlocationsmb-old.txt" "P:smb-new.txt"


mklink "C:ProgramDatasymboliclink-oldlocationsmb-old.txt" "cifssharesmb-new.txt"

Application of Symbolic Links in VMware Horizon and VDI

A creative way of redirecting saved data for an application in VDI in a persistent or non-persistent disk configuration, is to utilize environmental variables (such as those listed in this article: to redirect data to a user share or directory. It is important to make sure that the symbolic link is created on the deployed virtual machine and not the golden image as environmental variables are applied to the existing user and desktop, not the one to be deployed.

For example, if I want to have my symbolic link write to the user directory by utilizing the %USERNAME% variable and I try to create symbolic link on the golden image (in my example I logged on with the administrator account), the symbolic link is immediately created and %USERNAME% will equal administrator. To get around this, a script or GPO can be utilized to create the symbolic link after the user has logged into their persistent desktop or the linked clone.

Example code has been provided for reference.

mklink "C:ProgramDatasymboliclink-oldlocationsmb-old.txt" "cifsshare%USERNAME%smb-new.txt"


Resources Used
Creating Symbolic Links, Accessed May 05, 2014
Difference between relative & absolute symbolic links?, Accessed June 10, 2015.
Mklink Accessed May 05, 2014
Recognized Environment Variables, Accessed June 10, 2015
What is the difference between symbolic and hard links?, Accessed June 10, 2015.
Windows 7: How to Create Symlinks (Symbolic Links), Accessed May 05, 2014
Windows Environmental Variables, Accessed June 10, 2015

KeepWatch by InterWorks

Whether you need support for one platform or many, our technical experts have you covered.

More About the Author

Ideen Jahanshahi

Solutions Architect
Veeam NAS Backup: Integrating with Dell EMC Isilon Those of us who have been in the backup realm a long time remember when Veeam Backup and Replication (Veeam B&R) was one of the top ...
The InterWorks Approach to Great Consulting: Part 3 If you’ve been following along, you know that this blog miniseries is all about dissecting the shared traits that some of my most ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK


Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Geschäftsführer: Mel Stephenson

Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072


Love our blog? You should see our emails. Sign up for our newsletter!