So right now it's "C:\Users\USER". Anyone know how this might have happened?
Where is the name of this folder usually set? I'm assuming during setup?
C:\Users\%user%\Desktop refers to a location that is unavailable. . . .
C:\users\%user% is missing
How do you store a list of users (C:\Users) in PowerShell to use later on in the same script? - Stack Overflow
The python code needs to get the user's username to open a file on the C:/Users/USERNAME/ directory - Stack Overflow
Videos
Yes, %LocalAppData%\Programs is the default folder to "install programs for a single user only" in MS Windows. It's been available since Windows 7/Windows Server 2008 R2.
Such programs are often called Per-User Applications (PUA) in MS documents. While the knowledge about the existence of PUA now is widely spread, many still are not aware of the infrastructure, environment, and tools that MS provided to support them. The folder in question is a part of that infrastructure.
Note: This folder may have a different name depending on the specific Windows setup. The programs should use the corresponding KNOWNFOLDERID constant FOLDERID_UserProgramFiles to locate it properly.
References:
- Windows Installer Documentation → About Windows Installer → Installation Context
- The Windows Shell Documentation → Shell Constants, Enumerations and Flags → KNOWNFOLDERID → FOLDERID_UserProgramFiles
However, I'm still looking for more straightforward answers. Is
C:\Users\MyUser\AppData\Local\Programsthe folder where installers install programs for a single user only?
Applications installed to %LocalAppData% would only be available to the user that installed it. Additionally, if a user were on an Active Directory domain, it wouldn’t be synchronized to other machines.
%LocalAppData% is not synchronized between the domain, which means the data only exists locally on the machine.
Is it like a Program Files folder but only for that particular user?
%LocalAppData% is not like %ProgramFiles% other than it’s just another directory. There are significant differences between the two directories.
Is this the recommended directory for installing single-user programs?
%LocalAppData% is a perfectly valid directory that applications can be installed to. In fact, a user can install an application to any directory they have the proper permissions to, there really are no invalid application installation directories.
I want to figure out if that’s the directory to install programs to for that user.
You certainly can choose to install an application like Visual Studio Code to %LocalAppData%\Programs to this directory if you want.
Since you have been specifically interested in Visual Studio Code, I found the following documentation on it.
VS Code provides both Windows user and system level setups. Installing the user setup does not require Administrator privileges as the location will be under your user Local AppData (LOCALAPPDATA) folder. User setup also provides a smoother background update experience.
The system setup requires elevation to Administrator privileges and will place the installation under Program Files.
By default, VS Code is installed under
C:\users\{username}\AppData\Local\Programs\Microsoft VS Code.
Source:
What is "%localappdata%\Programs" ?
How to COMPLETELY uninstall Visual Studio Code from Windows 10
What is the difference between ProgramData and AppData?
Visual Studio Code on Windows
Hmm, yeah that looks like it should be OK to me. Or at least nothing is jumping out.
Is it just the one user on that machine that runs into this problem or do other users get the same sort of thing?
If it’s the one user I think my next stop would be the registry:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
In there should be all of the redirects. Could be that something has gotten stuck on something and could be corrected.
If it’s multiple users I guess RSOP on that machine would be my next port of call.
C:\Users%user%\Desktop refers to a location that is unavailable. . . .
This happened after i made a GPO for folder redirection. I tested it profusely, and it seemed to work just fine before i started taking baby steps/(more testing) while implementing it. So all looked good and i went for it. All machines worked out ok except one. And on this one machine, i get this error with opening just about any directory. the folder redirection worked out, but it was supposed to leave the desktop folder on the local machine too (Like all the others within the exact same policy).

IF I’m not figuring this one out tonight. This will be an annoying issue for me and the user tomorrow.
What I need is a folder filled with .txt files with the name of each computer name that is in the ComputerUp.txt file
Using the file system for this is unnecessary - you can store this information in a variable in-memory instead:
# Read the list of computers from disk
$Computers = Get-Content .\path\to\ComputerUp.txt
# Create a dictionary to hold ComputerName->ListOfUsers data
$UsersPerComputer = [ordered]@{}
foreach($computer in $Computers){
# enumerate the remote folder names
$listOfNames = Get-ChildItem \\$Computer\C$\Users |Select-Object -ExpandProperty Name
# assign the list to the dictionary, use the computer name as the key
$UsersPerComputer[$computer] = $listOfNames
}
Now you can retrieve the list for a single computer by name:
$targetMachine = 'Computer123'
$UsersPerComputer[$targetMachine] # this will resolve to the list of user folder names we got from Computer123
Seems like you're confusing foreach with ForeEach-Object.
- With
foreachyour script would look like this:
$Computers = Get-Content "C:\Temp\Cache Cleanup Project\June 10 Lists\ComputerUp.txt"
foreach ($Computer in $Computers)
{
(Get-ChildItem "\\$Computer\C$\Users").Name |
Out-File "C:\temp cache cleanup project\Computer Users\$Computer.txt"
}
- With
ForEach-Objectit would look like this:
Get-Content "C:\Temp\Cache Cleanup Project\June 10 Lists\ComputerUp.txt" | ForEach-Object {
(Get-ChildItem "\\$_\C$\Users").Name |
Out-File "C:\temp cache cleanup project\Computer Users\$_.txt"
}
As a side note, doing this should get the job done exponentially faster:
$Computers = Get-Content "C:\Temp\Cache Cleanup Project\June 10 Lists\ComputerUp.txt"
$result = Invoke-Command -ComputerName $Computers -ScriptBlock {
Get-ChildItem C:\Users
}
$result | Group-Object PSComputerName | ForEach-Object {
$_.Group.Name | Out-File "C:\temp cache cleanup project\Computer Users\$($_.Name).txt"
}
Three ways to do this using the os module:
- Use
os.getlogin():
import os
>>> os.path.join("C:", os.sep, "Users", os.getlogin(), "Desktop")
'C:\\Users\\your_username\\Desktop'
- Use
os.environ():
>>> os.path.join(os.environ['userprofile'], "Desktop")
'C:\\Users\\your_username\\Desktop'
- Use
os.path.exapndvars():
>>> os.path.join(os.path.expandvars("%userprofile%"), "Desktop")
'C:\\Users\\your_username\\Desktop'
you can use expanduser and ~ for that :
import os
open(os.path.expanduser('~\\Desktop\\data3.txt'))
or if you want to use os.path.join :
open(os.path.join(os.path.expanduser('~'), 'Desktop', 'data3.txt'))
Only C:\ProgramData actually exists as a "real" folder. C:\Users\All Users is a symbolic link to C:\ProgramData. That is, C:\Users\All Users points to C:\ProgramData, so if you navigate to the former, you are automatically redirected to the latter. That is why they appear identical.
C:\ProgramData is known as the "All Users Profile" and is required for the correct operation of Windows 7. Please do not delete it, if Windows even lets you.
C:\Users\All Users is there for backward compatibility. Poorly-written applications do not retrieve the path of the All Users Profile correctly. They say, "Windows, give me the name of the profiles directory." Windows says, "C:\Users." And the program says, "Okay, I know the All Users profile is called All Users and it's inside the profiles directory, so it must be C:\Users\All Users." Really, what the program should say to Windows is, "Windows, give me the path of the all users profile," to which Windows would say, "C:\ProgramData."
They are the same folder. Users\All Users is a junction to \ProgramData. From Application Compatibility: Junction Points and Backup Applications:
All Users legacy folder junction requirements:
Sym links creation location Destination
..\Users\All Users ..\ProgramData
Users\All Users is a link to the ProgramData folder for legacy reasons. It is a junction point (symlink in the UNIX world) and not a copy of the data. I have only the ProgramData folder on my Windows 7 (x64) computer. My guess it is safe to delete the junction point, but not necessary. I don't recommend deleting ProgramData.