none
WTSSetUserConfig fails on Windows Server 2008 RRS feed

  • Question

  • I want to toggle the a Terminal Services flag using the WTSSetUserConfig() function[1]. In the "Environment"-properties tab there is a checkbox called "Start the following program at logon". I want to delete this flag. My code for this tasks looks like this:

    DWORD value = 1;
    hr = WTSSetUserConfigW(pServer, pUser, WTSUserConfigfInheritInitialProgram, (wchar_t *) &value, sizeof(value)));

    This works well up to Windows Server 2003. On Windows Server 2008 the function does not return an error but the flag remains set. The other way works well, the following code sets the flag on Windows Server 2008:

    DWORD value = 0;
    hr = WTSSetUserConfigW(pServer, pUser, WTSUserConfigfInheritInitialProgram, (wchar_t *) &value, sizeof(value)));

    Has anyone a clue, what is wrong here? It looks like the behaviour of the API changed in the latest Windows Server release.

    I'm aware of the IADsTSUserEx [2] API but it does not offer anything to toggle this flag. It is only possible to set the TerminalServicesInitialProgram and TerminalServicesWorkDirectory properties.

    [1] http://msdn.microsoft.com/en-us/library/aa383844(VS.85).aspx
    [2] http://msdn.microsoft.com/en-us/library/aa380823(VS.85).aspx
    Monday, February 23, 2009 12:17 PM

All replies

  • Hello Bernhard:

    Apologies for the delay in reply. Can you please clarify what you are trying to do and how you verified that this API is not working with value 1? I just tried a little experiment using the same API with the same parameters you mentioned. When I use WTSQueryUserConfig to read the same value, it returns the value as expected.

    When the API is invoked with value 1 for WTSUserConfigfInheritInitialProgram, the initial program specified by client is supposed to be started on logon, unless there are other settings on server side (e.g. group policy or listener policy) that may prevent it. When this API is invoked with value 0 for the same parameter, the user always gets full desktop regardless of what client specifies.

    On Windows Server 2003, if WTSUserConfigInheritInitialProgram = 1, which by default it is, initial program specified by client gets started on logon. However, on Windows Server 2008, when the server is in remote admin mode, remotely connecting user always gets full desktop. Only when TS role is installed, the initial program specified on the client gets started on logon.

    Since this value is set to 1 by default, I am wondering why you are using this API to set it and setting this value to 1 using API is not working for you.

    Thanx and Best Regards!

    Mahesh
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, March 10, 2009 7:54 PM