I have BAT scripts which are nothing tricky and work fine on XP. But on Win 7, about 1 in 5 executions of mkdir following rmdir give a mystery Access Denied. E.g.
S:\TLIB importing\! Curtains\2 To process>rmdir temp3allout /s /q
S:\TLIB importing\! Curtains\2 To process>mkdir temp3allout
Access is denied.
After this, when I try in Explorer, it has no problem making that directory. Running thatBAT again usually succeeds.
Any idea what’s going on here?
Win XP disc was a regular 2Gb drive. Win 7 disc is a 2Gb Intel RST RAID1 array with caching and flushing disabled https://i.stack.imgur.com/vDZRB.png .
asked Aug 19, 2014 at 23:13
12
This happens when the file system hasn’t finished deleting the directory yet.
Sometimes this will happen synchronously, i.e., before the rmdir command completes, but sometimes there will be a very short but nonzero delay. (In XP it was always synchronous, IIRC.)
If possible, avoid deleting and immediately recreating directories; if you can’t avoid it, you’ll need to detect the failure and retry.
You should probably also test and if necessary retry the rmdir; sometimes rmdir runs into the same problem and fails to delete the entire directory tree.
answered Aug 21, 2014 at 20:42
Harry JohnstonHarry Johnston
35.7k6 gold badges68 silver badges159 bronze badges
2
Because that directory or file in that directory is open in some editor,first you have to close that file/directory from editor and then try.
These error usually comes when we create some directory and then delete it,but it is partially deleted and we create new directory with same name.
answered Aug 16, 2018 at 6:02
I’m trying create folder:
import os
mypath = (r'C:\Program Files\my_folder')
if not os.path.isdir(mypath):
os.makedirs(mypath)
I got error:
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'C:\\Program Files\\my_folder'
asked Apr 30, 2016 at 14:12
The script does not have permissions to write to the Program Files
folder. In Windows, this is a folder that is protected by very high level of permissions and generally should not be written to, except by installers.
Assuming you need to store data specific to the machine, use the %PROGRAMDATA% environment variable instead. Note that when accessing an environment variable in Python, do not use the %
symbol.
import os
mypath = os.path.join(os.getenv('programdata'), 'my_folder')
if not os.path.isdir(mypath):
os.makedirs(mypath)
print (mypath)
Will create the folder, and output the path:
C:\ProgramData\my_folder
If you need to store data for each user, use the %APPDATA%
environment variable instead.
answered Apr 30, 2016 at 14:18
SteveSteve
7,1912 gold badges30 silver badges53 bronze badges
9
Cannot create directory with mkdir
even though touch
, rm
, rmdir
, mv
all works fine.
Microsoft Windows [Version 10.0.19546.1000]
Arch Linux distro created with
wsl --export Arch D:\arch.tar
wsl --import Arch2 D:\WSL\Arch2 D:\arch.tar --version 2
cd /mnt/d/
mkdir a
gives
mkdir: cannot create directory ‘a’: Permission denied
Works fine at home directory though
cd /mnt/c/Users/user
mkdir a
no problem here…
Where should I start to look for a solution for this?
Can you reproduce this when using C:\ instead?
Give the other Arch image a try, I know it’s a good image.
What are the permissions in the folder what you are trying to create a folder?
Have you tried chown?
chown, chmod all works alongside touch, rm, rmdir, mv, etc. I just noticed mkdir wouldn’t work when git clone gives me permission denied.
Thanks for helping btw! Will try a clean image instead of exporting from one I currently have.
I have the same issue, I am trying to create a directory so that I can mount the drive
I delete a git dict in windows explorer, then mkdir failed in WSL terminal.
I just upgraded to ubuntu version 2 and I’m getting the same issue. I can’t mkdir on my drives in /mnt/c and /mnt/d, but it works fine in my home folder and other areas. All other operations work fine. Even running with sudo doesn’t help. My app that I’m working on also can’t create folders.
In my case it was a mount issue, or at least changing the mount options fixed it. Running the following command from https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ worked for me:
sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata
It’s unclear but the command seems to be permanent. I’m not sure what happened during the upgrade from WSL 1 to 2 that affected this.
Hello there,
In my case, this issue was solved by: giving the Full control permission to your Windows account for this directory with Security tab
Said, I’d created a directory at /c/src
and trying to develop there, but the «User» group doesn’t have Full control permission at that path, so the folder creation is failed in WSL in my case.
Then I was added the Full control permission to my Windows account at that folder, and the mkdir
worked perfectly in that directory.
Turns out my mount solution didn’t last through a reboot, but the Full Control to users fixed it, thanks @stu85010.
I have the same issue on Ubuntu 20.04.2 LTS. Besides other commands like touch and I/O redirection fail with the same error. Why it happens?
Maybe this issue help.
You have to launch Git Bash as an administrator. Simple as that, it helped me.
try command sudo chown -R "yourusername" .
replace «yourusername» with the name of the user
try command
sudo chown -R "yourusername" .
replace «yourusername» with the name of the user
Thanks, this worked for me
try command
sudo chown -R "yourusername" .
replace «yourusername» with the name of the user
you saved my life bro 😊😊😊
try command
sudo chown -R "yourusername" .
replace «yourusername» with the name of the user
you saved my day 😊 thanks!
In my case it was a mount issue, or at least changing the mount options fixed it. Running the following command from https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ worked for me:
sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata
It’s unclear but the command seems to be permanent. I’m not sure what happened during the upgrade from WSL 1 to 2 that affected this.
This is the error I am getting while trying to run a few jupyter notebooks. Will this command help with this issue?
mkdir("/pathname1/", 0777);
$dir = mkdir("/pathname/");
if($dir)
echo "Директория создана";
else
echo "Не удалось создать директорию";
Выдает вот это:
Warning: mkdir(): Отказано в доступе in /opt/lampp/htdocs/cloud/index.php on line 35
Warning: mkdir(): Отказано в доступе in /opt/lampp/htdocs/cloud/index.php on line 36
Не удалось создать директорию
Почему так?
-
Вопрос задан
-
4463 просмотра
Пригласить эксперта
//относительно текущего пути
$dir=mkdir(dirname(__FILE__)."/pathname1/subpathname1/subpathname2", 0777, true);
Потому что у PHP нет прав на запись в директории, в которой вы хотите сделать новую.
Выставьте соответсвующие права и группу или хозяина для этой директории и всё заработает.
-
Показать ещё
Загружается…
08 окт. 2023, в 23:50
5000 руб./за проект
08 окт. 2023, в 21:59
1000 руб./в час
08 окт. 2023, в 20:00
10000 руб./за проект
Минуточку внимания
Explore multiple ways to regain full control over your folders
by Matthew Adams
Matthew is a freelancer who has produced a variety of articles on various topics related to technology. His main focus is the Windows OS and all the things… read more
Updated on
Fact checked by
Alex Serban
After moving away from the corporate work-style, Alex has found rewards in a lifestyle of constant analysis, team coordination and pestering his colleagues. Holding an MCSA Windows Server… read more
- If you can’t create a new folder on Windows 10, it might be because a program has altered some registry keys on your PC.
- In order to fix it, make sure you disable the directory protection features in your antivirus.
- Also, consider restoring your system to a previous state, and read on for more solutions!
XINSTALL BY CLICKING THE DOWNLOAD
FILE
Has the New > Folder option disappeared from your desktop and File Explorer context menus in Windows 10? Are File Explorer’s New item and New folder buttons malfunctioning?
If that’s the case, a third-party software utility accidentally erased the required keys for the new folder options. If you can’t create a new folder in Windows 10, this is largely down to corrupted registry keys; and here are a few ways you can fix it and restore your new folder option.
Why can’t I create a new folder in Windows 10?
If you are trying to add a new folder on your PC and it is not creating, it’s likely the corrupt system files are to blame. Also, running an older version of Windows has been found to cause this problem.
Besides, there may be misconfigured settings in the antivirus, both built-in and third-party, responsible here, so make sure to check for these as well.
In case you are unable to create a new folder in a specific location, it could be that the required permissions have not been granted. Here, you could modify the folder permissions and take full control.
This is most likely a permission issue, but many reported that new folders cause File Explorer to freeze. If this happens, it’s possible that there’s a bug that causes this problem.
Some users tried creating a new folder with keyboard shortcuts, and this is a solid workaround that might work for some.
Below are some of the variations of this issue reported by users:
- Cannot create a new folder on desktop Windows 10, USB drive, flash drive – Many users reported this problem on their PC, but it can also occur on USB and flash drives. If you’re having this problem, be sure to try some of our solutions.
- Can’t create new folder Windows 8 – This issue can also appear on Windows 8, and although Windows 10 and Windows 8 have certain differences, most of our solutions should work with Windows 8 as well.
- New folder option missing Windows 10 – If you have this problem, you should be able to fix it with one of our solutions.
- Unable to create the folder ‘new folder’ access is denied – Sometimes you might get an error message saying that access is denied when creating a new folder. If that’s the case, be sure to check if you have administrative privileges over that directory.
- Right-click create new folder missing – In some cases, the new folder option might be missing from the right-click menu. If that’s so, you can fix the problem by making a couple of changes to your registry.
- New folder option missing in Windows 7/11 – To fix the folder access denied issue on Windows 10, you need to take ownership of the folder. Also, you might need to change your user account to admin.
- Create folder in registry in Windows 10 – For detailed steps and more fixes for this issue, check our guide on how to fix the access denied error on Windows 10.
How do I add a new folder in Windows 10?
The easiest way to create a new folder on Windows 10 and other versions on Desktop, File Explorer, and other locations is to use the Ctrl + Shift + N keys.
This shortcut works is universal and works in most locations.
What to do if I can’t create new folders in Windows 10?
- Why can’t I create a new folder in Windows 10?
- How do I add a new folder in Windows 10?
- What to do if I can’t create new folders in Windows 10?
- 1. Edit the Registry manually
- 2. Uninstall problematic applications
- 3. Run an SFC scan
- 4. Use Command Prompt to create a directory
- 5. Run a System Restore
- 6. Remove problematic updates
- 7. Reset File Explorer
- 8. Perform a clean boot
- 9. Disable controlled folder access
Before exploring some sophisticated fixes, you can try using the Ctrl + Shift + N shortcut and see of that works. Also, make sure your antivirus software is not blocking the file directories. If these fail, you can check our solutions below to fix the issue quickly.
How we test, review and rate?
We have worked for the past 6 months on building a new review system on how we produce content. Using it, we have subsequently redone most of our articles to provide actual hands-on expertise on the guides we made.
For more details you can read how we test, review, and rate at WindowsReport.
1. Edit the Registry manually
You could do some manual registry editing to fix new folder options. Edit the registry to fix the folder options explained as below.
1. Press the Windows key + R, type regedit, and click OK.
2. Browse to the key below in the Registry Editor window:ComputerHKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers.
3. Select ContextMenuHandlers in the left pane and right-click an empty space on the right.
4. Now, select New, then Key.
5. Enter New as the title for the key.
6.Select the New key and double-click Default on the right to open the Edit String window.
7. Enter {D969A300-E7FF-11d0-A93B-00A0C90F2719} in the Value data box and click OK to close the window.
8. Now, close the Registry Editor window and right-click the desktop to set up a new folder.
2. Uninstall problematic applications
- Press the Windows key + I to open the Settings app and select the Apps option.
- Locate and click on the app you want to remove and click the Uninstall button.
- Finally, follow the onscreen instructions to complete the process.
According to users, sometimes third-party applications like BootDeleter can lead to this problem. To fix the issue, users are recommending removing all problematic applications from their PC.
Several users reported that they fixed the problem by making changes in their registry from Solution 1 after deleting the BootDeleter software, so be sure to try that.
If you need to erase all the unwanted apps that may cause this folder issue, you can find valuable solutions with one of the best uninstaller software for Windows 10 PCs in CCleaner. With this tool, you can remove the problematic software and all its components with a few clicks.
3. Run an SFC scan
- Press the Windows key + S, type cmd, and click on Run as administrator to start Command Prompt as administrator.
- Copy and paste the command below and hit Enter:
sfc/ scannow
- Wait for the scan to complete and try to create a new folder again.
Sometimes, the reason you can’t create a new folder on Windows 10 is because of broken or corrupt system files. Running the System File Checker should help you restore normalcy in this case.
Alternatively, you can use a dedicated tool in Fortect to get your system files back to normal.
This tool employs a simpler way to repair corrupted files and get rid of system errors. It does this by automatically scanning your PC for problematic files and acting accordingly.
Fortect
To avoid these issues, restore your system to an earlier version or create a restore point now.
4. Use Command Prompt to create a directory
- Launch Command Prompt as administrator.
- When Command Prompt starts, type cd / and hit Enter to navigate to the root directory.
- Now, enter the command below and hit Enter in order to create a new directory:
mkdir FolderName
- By doing that you’ll create a new folder on your C drive.
After doing that, you should be able to create new directories without any issues. Several users reported that they managed to fix the problem simply by using Command Prompt to create a new folder on their PC.
5. Run a System Restore
- Enter system restore into the Cortana search box and select Create a restore point.
- Click System Restore in the System Properties window.
- Click the Next button.
- Choose a restore point when the New folder option was working fine and click Next.
- Finally, click the Finish button to complete the process.
Restoring your PC to a point when the new folder option was working well is another option that has proved to solve this issue for many users. If you have not created a restore point in the past, check our guide on how to create and use System Restore.
If you feel that our explanation above is not clear enough, we have a dedicated article
6. Remove problematic updates
- Press the Windows key + I and select Update & Security.
- Choose the View installed update history option.
- Select Uninstall updates to open the Control Panel.
- Now double-click the update you want to remove to uninstall it.
If this issue started occurring recently, the cause might be a Windows Update. Sometimes an update can cause this problem to occur, and if that’s the case, you need to find and remove the problematic updates.
Once you remove the update, check if the problem is resolved. If the problem doesn’t appear, you should block the update from installing.
Windows 10 tends to install all updates automatically, and if you don’t block the update, Windows will install it again causing the issue to reappear.
- FIX: Cannot delete files, folders or icons in Windows 10/11
- How to fix the red X mark on folders in Windows 10/11
- How to Access the User Folder on an Old Hard Drive [Windows 11 Guide]
- Folder Disappeared on Windows 11? How to Get it Back
7. Reset File Explorer
- Press the Windows key + X and select the Task Manager option.
- Right-click on Windows Explorer and select the End task.
- Now, try to create a new folder. If it still does not work, press the Windows key + R to open the Run utility.
- Type SYSDM.CPL and hit Enter.
- Click the Advanced tab at the top, followed by the Settings button under the Performance section.
- Click the Advanced tab at the top and set Adjust the performance of: to Programs in the Processor Scheduling section.
- Now, go to the Virtual Memory section in the same window and click the Change… button.
- From here, check the box for Automatically manage paging file sizes for all drives.
- Finally, click the OK button.
At times, there might be a problem with File Explorer or you might have altered the settings, leading to the can’t create a new folder on Windows 10 issue. In this case, the fix above should help resolve the problem.
8. Perform a clean boot
- Press the Windows key + R, type msconfig, and click OK.
- Click the Services tab at the top, then check the box for Hide all Microsoft services, and click the Disable all button.
- Click the Startup tab, followed by Open Task Manager.
- Right-click each of the services there and select Disable.
- Now, go back to the services window, click the Apply button followed by OK and restart your PC.
Third-party are among the major causes of this issue. Performing a cleaning boot starts your system with only the required processes. Now, you can try creating the new folder again.
9. Disable controlled folder access
- Press the Windows key + S and type controlled folder.
- Choose the Controlled folder access option.
- Toggle the switch before Controlled folder access backwards to disable it and close the Window.
Windows Defender provides security and can also control access to some folders. This feature might be the reason you can’t open a new folder. Disabling it should help fix this issue in this case.
So those are our solutions to effectively fix and restore new folder options if you cannot create new folders in Windows 10.
First, restore Windows 10 to a previous date with the System Restore tool; and if that doesn’t fix it edit the registry or set up the registry script as outlined above.
Sometimes, you can’t create a new folder simply because you don’t have enough privileges. Therefore, you should read our article on how to fix the problem if the system can’t write to the specified device.
Feel free to let us know if you were able to fix this issue with any of our solutions in the comment below.