The fastest way to change desktop folder location programmatically
<p>I want to create an application that allows users to have different icons on different Windows 10 desktops. I can deal with the switching of virtual desktops using the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms687107(v=vs.85).aspx" rel="nofollow noreferrer">Window Station and Desktop functions</a> and the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/mt186440(v=vs.85).aspx" rel="nofollow noreferrer">Virtual Desktop Shell Interface</a>. So now I know how to detect that a desktop has been switched and I need to change the location of the Desktop User Folder as fast as possible.</p>

<p>I know there are two ways of doing this in the User Interface:</p>

<p>A) Via User Folders' properties</p>

<ol>
<li>Open <code>%HomePath%/Desktop</code> in Explorer</li>
<li>Right click on background, open Properties</li>
<li>In tab Location type in the new path</li>
<li>Hit OK and then No (as you don't want to move the files)</li>
<li>Sometimes needed: click on desktop, press F2</li>
</ol>

<p>.</p>

<p>B) Via Registry</p>

<ol>
<li>Change <code>Desktop</code> in <code>HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders</code> to the new address</li>
<li>Relog</li>
</ol>

<p>.</p>

<p>The B option would be ideal for a programmatical solution if it wasn't for that relog part. Which is, as you can certainly understand, a bit of a dealbreaker.</p>