Cmdline script to recreate AppData folder (Non-Admin)

Arvind Kumar 6 Reputation points

I am looking for a simple cmdline script or set of commands in a correct sequence to recreate AppData folder along with all the symlinks and correct permissions / folder structure.

This script or set of commands should be able to run with Non-Admin priviledges

Target OS: Windows 10

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,183 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,181 Reputation points

    Hi there,

    This can be accomplished with a loop. In order for the script below to work, you will need to place test.xml in the same location as the script.

    $Users = (Get-ChildItem C:\Users).Name

    ForEach($User in $Users) {

    New-Item -Path "C:\Users\$User\AppData\Roaming\" -Name "triage" -ItemType "directory" -ErrorAction SilentlyContinue  
    Copy-item "$PSScriptroot\test.xml" -destination "C:\Users\$user\AppData\Roaming\triage"  


    How to make a file in localappdata location using powershell


    --If the reply is helpful, please Upvote and Accept it as an answer--

  2. MotoX80 30,831 Reputation points

    Disclaimer: use at your own risk.

    I found 5 junctions. If you are restoring your own account's appdata this should recreate them. If not, replace %username% with the userid.

    md C:\Users\%username%\AppData\Local  
    cd C:\Users\%username%\AppData\Local  
    mklink /j "Application Data"  C:\Users\%username%\AppData\Local  
    mklink /j  History C:\Users\%username%\AppData\Local\Microsoft\Windows\History  
    mklink /j  "Temporary Internet Files" C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache  
    md C:\Users\%username%\AppData\Local\Microsoft\Windows  
    cd C:\Users\%username%\AppData\Local\Microsoft\Windows  
    mklink /j  "Temporary Internet Files" C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache  
    md C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache  
    cd C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache  
    mklink /j  Content.IE5 C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache\IE  

    For permissions, I happen to have a PS script that analyzes a folder structure and generates the icacls commands to reset permissions on the folders. It doesn't look at files though. I ran this on my testuser account on a Win10 21H2 VM. You would need to change all instances of "testuser" to your account name. You may want to pick and choose which ones you want to apply.


    0 comments No comments