The Toolkit Forums General $envAppData

  • Author
  • Boonhock
    Post count: 2

    Hi everyone! Thanks for creating this awesome script!

    Here is my question.I’m using SCCM to deploy some files to my end users.
    I read the manual, the variable usage like below.
    $envAppData %APPDATA% (e.g. C:\Users\{username}\AppData\Roaming)

    So this is my code.
    Copy-File -Path “$dirFiles\Document Themes” -Destination “$envAppData\Microsoft\Templates\” -Recurse -ContinueOnError $true

    So it should be copy the document themes into C:\Users\{username}\AppData\Roaming\Microsoft\Templates\


    [Installation] :: Copy file(s) recursively in path [C:\windows\ccmcache\as\Files\Document Themes] to destination [C:\windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Templates\].

    Why will it copy to config\systemprofile?

    Appreciate if somebody can help out there 🙂

  • Dan Cunningham
    Post count: 7

    This is because the SCCM app is deploying as SYSTEM. You’d need to change this to run as the user for $envAppData to pick up the current user’s profile – a better method would be to use a separate script to populate the files to the Templates folder and use the Set-ActiveSetup function in the Toolkit.

    Hope this helps. Dan

  • Boonhock
    Post count: 2

    Hi Dan, thanks for your quick reply! really appreciate it!

    Sorry, i’m very noob on powershell so I’m little bit confuse on the Set-ActiveSetup function.

    So let say i put all my files which need to copy to %appdata% to a folder at C:\TempFolders. And then with set-activesetup function, every time a new user login to this computer, it will go C:\Tempfolders to run the following command?

    Copy-File -Path “$dirFiles\Document Themes” -Destination “C:\TempFolders\” -Recurse -ContinueOnError $true

    Set-ActiveSetup -StubExePath “$envWinDir\system32\cmd.exe” -Arguments ‘xcopy C:\TempFolders\Document Themes %appdata%\Microsoft\Templates\’ -Description ‘Settings up your profile’


  • Dan Cunningham
    Post count: 7

    Yep, that’d pretty much be it. However you need to encapsulate the folder with quotes, so:

    Set-ActiveSetup -StubExePath "$envWinDir\system32\cmd.exe" -Arguments "xcopy '"C:\TempFolders\Document Themes'" '"%AppData%\Microsoft\Templates\'"" -Description "Settings up your profile"

    Think that should do it.


You must be logged in to reply to this topic.