How to set User Tile image Windows Server 2012?

Posted by moontear on Server Fault See other posts from Server Fault or by moontear
Published on 2012-11-25T22:55:42Z Indexed on 2012/11/25 23:07 UTC
Read the original article Hit count: 377

I found this nice article of how to add a user tile image via code:

http://joco.name/2010/12/06/i-discovered-the-new-windows-user-tile-api/
This is also explained in depth here: http://msitpros.com/?p=1036

I have problems with doing this in Windows Server 2012. Whenever I run the code:

using System;
using System.Runtime.InteropServices;

namespace FejesJoco
{
    class Program
    {
        [DllImport("shell32.dll", EntryPoint = "#262", CharSet = CharSet.Unicode, PreserveSig = false)]
        public static extern void SetUserTile(string username, int whatever, string picpath);

        [STAThread]
        static void Main(string[] args)
        {
            SetUserTile(args[0], 0, args[1]);
        }
    }
}

I get an exception:

Error HRESULT E_FAIL has been returned from a call to a COM component.

Can anyone get this to work and add a user tile image via code?

© Server Fault or respective owner

Related posts about windows-server-2012

Related posts about user-profile