none
MDT - Different desktop icons for each user account RRS feed

  • Question

  • Greetings folks, first-time poster here.

    I am relatively experienced with MDT (using MDT 2013 to deploy Windows 8 and 8.1, without Active Directory).


    Each client PC has three different user accounts, and each account needs to have different desktop icons.

    I have a batch file that creates the user accounts in a task sequence during deployment (see below)

    net user /add User1 pass123
    net localgroup administrators User1 /add


    and I have another batch file that copies the desired shortcuts to each user's desktop folder:

    xcopy.exe "%deployroot%\Files\Desktop Icons\User1\*.*"   "c:\Users\User1\Desktop" /Q /H /E /I /Y

    The problem is, as soon as you log on as "User1" for the first time, Windows 8 creates a new user profile in (C:\Users\).

    Usually by appending the PC's name to the end of it, e.g. (C:\Users\User1-WorkPC).

    Thus, the icons that I copied to (C:\Users\User1) get ignored.

    I can't seem to figure it out.

    Anyone have any advice?

    Wednesday, January 8, 2014 1:37 PM

Answers

  • Hi,

    This happens because of a couple of things:

    If you pre-create a user folder (by your xcopy command) and then log in for the first time, Windows will try to create the profile folder. It can't, because a folder with the user name already exists. Windows wil then by default create a folder username-domain. As this is not a domain computer, it ends up as user-computername. If windows can not create that one either, a sequential number is added, like user-computername.000.

    You should therefore NOT do the xcopy during your deployment. That way, when the user logs in for the first time, a folder username is created. Then use a logonscript to copy the icons.

    You can copy them to the %userprofile% variable with this command:

    xcopy.exe "\\server\share\Destop Icons\%username%\*.*" "%userprofile%\Desktop" /qheiy

    This single command can be used as a generic script for all three users, copying only the appropriate icons to the corresponding user.

    As an alternative, you can add this as a <Default User\RunOnce> command during deployment, so that any user has this script applied only once on the first logon.

    Hope this helps,

    Regards,

    Martin


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.




    Friday, January 17, 2014 7:34 AM

All replies

  • Are you trying to copy the files there before the first logon? that would cause Windows to create a "new" profile. I guess I would create a script that I add to run-once for the default account. That way the script will run once for the first logon for each account. The script then has to copy the icons depending on the username. So you would have to stage the script and icons to a different location first.

    Just as a clarification, I'm just thinking out loud. Not sure this actually works :)


    Tim Nilimaa | Blog: http://infoworks.tv | Twitter: @timnilimaa


    Thursday, January 16, 2014 9:15 PM
  • Hi,

    This happens because of a couple of things:

    If you pre-create a user folder (by your xcopy command) and then log in for the first time, Windows will try to create the profile folder. It can't, because a folder with the user name already exists. Windows wil then by default create a folder username-domain. As this is not a domain computer, it ends up as user-computername. If windows can not create that one either, a sequential number is added, like user-computername.000.

    You should therefore NOT do the xcopy during your deployment. That way, when the user logs in for the first time, a folder username is created. Then use a logonscript to copy the icons.

    You can copy them to the %userprofile% variable with this command:

    xcopy.exe "\\server\share\Destop Icons\%username%\*.*" "%userprofile%\Desktop" /qheiy

    This single command can be used as a generic script for all three users, copying only the appropriate icons to the corresponding user.

    As an alternative, you can add this as a <Default User\RunOnce> command during deployment, so that any user has this script applied only once on the first logon.

    Hope this helps,

    Regards,

    Martin


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.




    Friday, January 17, 2014 7:34 AM
  • Thanks, Martin

    I actually managed to solve the problem with the help of a colleague the day before you answered.

    Your summary of the problem was correct.

    Basically, my colleague and I ended up solving the problem like this:

    1) In the task sequence, under "State Restore", I added several "Run Command Line" steps to the "Custom Actions" Group. (See Screenshot)

    2) These steps would run batch files that would create the user profiles, then schedule a task so that the computer would login to that account on the next reboot.

    3) After each such step, I added a "restart computer" step, so now the PC would boot into that account. This takes care of the user account creation.

    4) After all the required accounts have been created, I could copy the icons to the respective desktops in the same way as Martin described.

    Here is the code for the steps:

    ::Copy Required Files ::This file gets copied over to the C Drive on the PC during the "Copy Required Files" step in the TS

    ::This file is called "CleanReg.bat" REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V AutoAdminLogon /t REG_SZ /d 1 /f REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V DefaultUserName /t REG_SZ /d Administrator /f REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V DefaultPassword /d 1 /t REG_SZ /f shutdown /r /t 1


    ::Add Scheduled Tasks
    ::Creates a scheduled task to trigger the "CleanReg.bat" file  on the first login of all the accounts that are going to be created
    
    schtasks /create /S %computername% /RU Student /SC ONLOGON /TN FirstLoginStudent /TR "C:\CleanReg.bat" /f
    schtasks /create /S %computername% /RU Testee /SC ONLOGON /TN FirstLoginTestee /TR "C:\CleanReg.bat" /f
    schtasks /create /S %computername% /RU "Access Control" /SC ONLOGON /TN FirstLoginAccessControl /TR "C:\CleanReg.bat" /f
    schtasks /create /S %computername% /RU Staff /SC ONLOGON /TN FirstLoginStaff /TR "C:\CleanReg.bat" /f


    ::Login As Student
    
    REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V AutoAdminLogon /t REG_SZ /d 1 /f
    REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V DefaultUserName /t REG_SZ /d Student /f
    REG ADD "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon" /V DefaultPassword /t REG_SZ /f


    ::Remove Scheduled Tasks
    
    schtasks /delete /tn FirstLoginStudent /f
    schtasks /delete /tn FirstLoginStaff /f
    schtasks /delete /tn FirstLoginTestee /f
    schtasks /delete /tn FirstLoginAccessControl /f

    ::Delete Required Files
    
    del C:\CleanReg.bat

    ::Copy Student Desktop Files (Rinse and Repeat for each account)
    
    xcopy %DEPLOYROOT%\CustomFiles\DesktopFiles\Student\*.* C:\Users\Student\Desktop\

    Now, MDT creates the account, logs into it, restarts, creates the next account, logs into that account etc.

    Then, after all the accounts have been created, it copies over the icons.

    I hope this helps someone! Thanks to all who replied!


    Intermediate MDT user

    • Proposed as answer by cmendao Monday, November 16, 2015 10:04 AM
    Friday, January 17, 2014 1:12 PM
  • Very cool logic there, Victor. I'll be storing this for later use. 
    Sunday, January 19, 2014 6:05 PM