Computer Hope

Microsoft => Microsoft DOS => Topic started by: circaal on February 13, 2020, 01:26:33 PM

Title: Batch file and rename junctions
Post by: circaal on February 13, 2020, 01:26:33 PM
Hello everyone,

Is it possible to rename a junction with patch or powershell. I'm trying to rename the C:\ProgramData\Application Data folder.

Code: [Select]
REN "C:\ProgramData\Application Data" "Application Data1"
But it doesn't work. and when I run /dir is doesn't show up but /dir /a it shows that Application Data is a junction and not a folder. So I was wondering if there is a way to do it. Thanks in advance
Title: Re: Batch file and rename junctions
Post by: Squashman on February 23, 2020, 01:55:01 AM
I would highly advise against this as many programs now store their configuration files in this directory.
Title: Re: Batch file and rename junctions
Post by: patio on February 23, 2020, 05:14:34 AM
If you rename it Windows will be borked...
Title: Re: Batch file and rename junctions
Post by: circaal on February 25, 2020, 01:09:25 PM
Well due to a workaround my company has found the renaming the folder fixes an install error I'm getting when installing a cisco program.
Title: Re: Batch file and rename junctions
Post by: BC_Programmer on February 26, 2020, 11:16:05 AM
The junction point is itself primarily for backwards compatibility. Vista changed the arrangement of folders and where special folders were. The short of it is that in XP the special folder was shared with a few other special folders, such that "Application Data" was available from that location, and so programs expected to be able to use <specialfolder>\Application Data but in Vista that folder no longer existed because the special folder was moved to it's own location. To fix compatibility problems, the junction point C:\ProgramData\Application Data was added which points back at C:\ProgramData to resolve that problem.

As for renaming it, The junction point has security permissions set on it. You'll want to first unset the Hidden and System attributes, then edit the security permissions in File Explorer to remove the deny entry denying everyone List contents/Read Data permissions. This should allow the rename to work, then you can add the security permission back and reset the hidden and system attributes.

Title: Re: Batch file and rename junctions
Post by: circaal on February 27, 2020, 12:25:18 PM
Thanks for your help BC, it looks like I am unable to edit any of the permissions for the EVERYONE group or any group for that matter. Even if I change the owner
Title: Re: Batch file and rename junctions
Post by: BC_Programmer on February 27, 2020, 05:26:10 PM
you will likely need to use a tool like psexec to elevate to the localsystem account, then use icacls to remove the deny permissions.
Title: Re: Batch file and rename junctions
Post by: circaal on February 28, 2020, 12:41:32 PM
Thanks so much for your help. I really appreciate it