Add account picture from command line 1809

Page 1 of 2 12 LastLast

  1. Posts : 425
    Windows 10
       #1

    Add account picture from command line 1809


    I want to have my script automatically set up an account picture for a user.

    In Windows 10 1809 17763 the account pictures are located at %APPDATA%\Microsoft\Windows\AccountPictures.

    Images are stored with a string name such as '81b56e057727e2f4', not an actual file name.

    The reference to this image in the registry is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AccountPicture

    However, putting the images in the correct folder and adding the registry key still does not display the account picture.

    Using RegFromApp and manually adding it via the settings app I see that it creates an entry at;

    HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\xxx\52C64B7E with a name of
    @windows.UI.Immersive.dll,-38306

    And its value is 'Account Picture'

    The problem is the xxx in the registry path above is different for each installation.

    The value at the end of the name seems to be constant.

    -38306 for a user account picture
    -23570 for the default account picture.

    So my question is how can I get the account picture to display from the script without having each user manually configure it?
      My Computer


  2. Posts : 7,607
    Windows 10 Home 20H2
       #2

    Wobitancrawfodi said:
    The problem is the xxx in the registry path above is different for each installation.
    Find the xxx via either of the following commands:

    (1) PowerShell
    Code:
    Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\MuiCache" -recurse|Format-table -hidetableheaders name|Out-File "$env:homeDrive$env:homePath\Desktop\Value.txt"

    (2) CMD
    Code:
    PowerShell Get-ChildItem -Path 'HKCU:\Software\Classes\Local Settings\MuiCache' -recurse ^|Format-table -hidetableheaders name > "%USERPROFILE%\Desktop\Value.txt"

    In both cases, the xxx can be found in "Value.txt" on the desktop.
      My Computer


  3. Posts : 425
    Windows 10
    Thread Starter
       #3

    That's awesome, and almost perfect. The output creates 6 lines in the text file.

    Code:
    .
    HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\1cf         
    HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\1cf\52C64B7E
    .
    .
    .
    The dots are there just to show that there are blank lines.

    I can grab line 3 by using 'skip=2' in the for command in batch to grab the line I need to use for the registry key.

    Thanks for your help.
      My Computer


  4. Posts : 10
    Windows 7 and 10
       #4

    Wobitancrawfodi said:
    That's awesome, and almost perfect. The output creates 6 lines in the text file.

    Code:
    .
    HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\1cf         
    HKEY_CURRENT_USER\Software\Classes\Local Settings\MuiCache\1cf\52C64B7E
    .
    .
    .
    The dots are there just to show that there are blank lines.

    I can grab line 3 by using 'skip=2' in the for command in batch to grab the line I need to use for the registry key.

    Thanks for your help.
    If you succeeded please share your scripts or details.
      My Computer


  5. Posts : 7,607
    Windows 10 Home 20H2
       #5

    The OP used Skip in a For...Do loop to exclude the first, unneeded lines.
      My Computer


  6. Posts : 425
    Windows 10
    Thread Starter
       #6

    Apologies. I have forgotten all about this post. This is what I ended up with;

    The APSrcID is different for each user and is set at the start of the script;

    Code:
    Set APSrcID=f8759757aaa1a98a
    Later...

    Code:
    IF EXIST "%SrcPath%\Account Pictures\" (
            Echo %time% Copying Account Pictures >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            copy "%SrcPath%\Account Pictures\*.*" "%APPDATA%\Microsoft\Windows\AccountPictures" /y >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            IF NOT "%APSrcID%"=="" (
                REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AccountPicture" /v SourceId /d %APSrcID% /t REG_SZ /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
                PowerShell Get-ChildItem -Path 'HKCU:\Software\Classes\Local Settings\MuiCache' -recurse ^|Format-table -hidetableheaders name > "%USERPROFILE%\Desktop\Value.txt"
                for /F "usebackq skip=2 delims=" %%G in ("%userprofile%\desktop\value.txt") do set MyKey=%%G 
                IF NOT "%MyKey%"=="" (
                    Echo %time% Adding pointer to Registry for MUICACHE at %MyKey% >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
                    REG ADD "%MyKey%" /v "@Windows.UI.Immersive.dll,-38306" /d "Account Picture" /t REG_SZ /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
                    del "%userprofile%\desktop\value.txt"
                )
            )
        )
    I have a backup script I run before reinstalling windows. It copies the account pictures to %SrcPath%\AccountPictures. In this case, %SrcPath% is set to %cd:~0,2%\PostInstall\%Username%. %APSrcID% is the file name of the picture to be used.

    I was going to script the determination of %APSrcID% but there were multiple files in some cases and no easy way to determine which one was being used. So I just added the name to the script.
      My Computer


  7. Posts : 7,607
    Windows 10 Home 20H2
       #7

    You can back up the image in the following folder:

    C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\AccountPictures

    Just double-click on the backup image or run the following command to import it.

    Start "" "D:\Photo.accountpicture-ms"
      My Computer


  8. Posts : 52
    Windows 10
       #8

    Matthew Wai said:
    You can back up the image in the following folder:
    Start "" "D:\Photo.accountpicture-ms"
    I know this is an old thread, but I just came across it in a search.

    This looked interesting so I thought I'd give it a try. It pops up an error box saying "error setting account picture. Please try again"

    The file I selected is an accountpicture-ms
      My Computer


  9. Posts : 7,607
    Windows 10 Home 20H2
       #9

    @jshs2020
    Do you have the same .accountpicture-ms file in the following folder?

    C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\AccountPictures
      My Computer


  10. Posts : 52
    Windows 10
       #10

    Matthew Wai said:
    @jshs2020
    Do you have the same .accountpicture-ms file in the following folder?

    C:\Users\%UserName%\AppData\Roaming\Microsoft\Windows\AccountPictures
    Yes. The file is only in that folder.

    Add account picture from command line 1809-acctpic.png
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:16.
Find Us




Windows 10 Forums