I have a folder without any file in it in my external hard. I am able to rename it, but not able to delete it. I ran CMD utility as an administrator and I tried the commands "del foldername", "rd foldername", "deltree foldername" (the last one was not allowed in Windows XP). They give me the message "Access is denied." for "rd foldername". How can I delete it?
I am not cmd guru, but simple as 1-2-3 is delete folder using system account.
at 11:11pm /interactive cmd
Now if system command appear, delete folder:
del foldername
try
attrib /s foldername
This should show you the directory attributes.
If the response is
R x:\dirname
then the directory is "read-only". In that case, execute
attrib -r foldername
and you should then be able to rd it.
It may be that the directory has (possibly hidden, possibly read-only) contents. The attrib /s should show these to you.
Related
I just installed the new LibreOffice version, but it failed because it couldn't delete the program folder in "C:\Program Files (x86)\LibreOffice 5", so I tried removing it with the Explorer and admin CMD, didn't work. Then I opened a System command prompt with psExec -i -s cmd and tried some commands on the folder:
rd /s program
takeown /r /f program
icacls program
Every command failed with "Access denied", so how do I remove it? I know that I could just ignore the windows permission system with a Linux distribution, but that's too much effort just for removing a folder.
I would suggest using the windows uninstall tool. If for some reason you can't do that try open cmd as admin and then type rd C:\Program Files (x86)\LibreOffice 5
I recently upgraded to Windows 10 from 7 on all of my computers, I have 4. I use Cobian backup which used to work fine on windows 7 however on 10 the shares of the folders aren't set correctly and although they say they are shared they don't appear across the network so I cant back them up.
I have however found I can go into each folder and change the permissions manually and they do appear but the problem is I have around 500 folders so I wanted to know if there was a quick command or batch file that could be run to set sharing permissions to everyone for every folder in the parent folder so I don't have to do it individually?
Try toggling the inheritance on the main parent folder. The permissions should trickle down.
You can use the icacls to change the permissions, like
icacls "C:\myFolder" /grant Everyone:M
For changing permissions to all sub directories you can use a for loop and give folder name to the icacls command,
#echo off
set Dir=C:\FolderName
for /d /r "%Dir%" %%a in (*) do (
echo Setting permissions for %%~dpa Folder
icacls %%~dpa /grant Everyone:M
)
Adjust set Dir = C:\FolderName with your path (base Folder).
I have a folder (cygwin) in my Program Files directory that can not be deleted. I am the administrator, and also the system administrator and still cannot delete the folder. I have tried deleting it with the command prompt (running it as administrator) and still cannot delete the folder. Is there any super be-all end-all way to delete this folder?
try to do this in cmd:
go to the cd where the folder is (example desktop)
cd desktop
attrib -s -h -r cygwin
cacls cygwin /e /c /g %username%:f
after that go to the cd were the folder his and try this
cd cygwin
del *.* /s /q
cd..
rd cygwin /s /q
I hope it works!
It's not clear whether what methods you've already used, but perhaps from an administrator command prompt you could try running "rd /s" on it? This would remove any subdirectories and files that might be hidden or set as system files that would otherwise prevent a delete.
I had the same issue, the folder was owned by a user that is not on my system. I don't claim to understand how that happened, but here is how I was able to finally remove the files.
First I had broken my cygwin install with previous delete commands, so I actually re-installed enough packages to have the terminal again. Then launched the terminal with administrator privileges and from cygwin prompt ran:
cd /cygdrive/c
chown -R `whoami` cygwin
This gave my current windows user the permissions to the folder and I was able to delete.
I have a script that runs in WinPE that takes a system drive with Windows installed and deletes everything off of the drive (keeping the filesystem intact).
When dealing with a Windows XP/Vista/7 installation it functions properly. attrib -S -A -H -I -R /S /D \ is run, and then everything is deleted.
However, within Windows 8, I run into an "Access Denied" error. For some reason, even as the SYSTEM user within WinPE, I can't edit the directory C:\ProgramData\Microsoft\Windows\LocationProvider. I can't use attrib to set attributes, I can't delete it - I can't even cd into it! dir /a just returns File Not Found.
Using rmdir /S /Q gives me the "Access Denied" error.
Assuming that the problem is related to permissions and/or ownership, you can work around it using the built-in robocopy tool - luckily, this is included in Windows PE.
First, create an empty directory, e.g., x:\empty and then run
robocopy /e /purge /b x:\empty c:\
The /b flag tells robocopy to use backup mode, which bypasses security.
Had the same problem. You need to take ownership first, for example using takeown.exe. Then fix permissions, for example using icacls.exe. Then proceed as you wish with copy, move, delete.
I'm a Mac/iPhone dev so I don't know very much about Windows scripting...
The point is I have to install a startup app on many computers, so I'd like to have a USB stick with two .bat files:
would be the actual "app"
would be the script that would copy the 1st.bat off my USB to the Windows startup folder...
How can I do that?
the name of my usb is "USB" and the name of my startup app is "startup.bat".
How I already said, I'm extremely lame in Windows programing, and I need it acutely ;)
Thanks A LOT!
Try the following script. This will cause the application to run whenever the current user logs in. Without administrative privilages, you won't be able to do it for all users in one go.
#Echo Off
CD /D %~dp0
Set StartupFolder=%AppData%\Microsoft\Windows\Start Menu\Programs\Startup
If Exist "%StartupFolder%" Goto :FoundStartup
Set StartupFolder=%UserProfile%\Start Menu\Programs\Startup
If Exist "%StartupFolder%" Goto :FoundStartup
Echo Cannot find Startup folder.
Exit /B
:FoundStartup
Copy "MyApp" "%StartupFolder%"
Each line does the following:
Turn off command echoing, making the script look cleaner to the end user.
Set the current directory to wherever this script is located.
Set the Startup folder's path as expected in Windows Vista or later.
If this folder exists, jump to the copying stage.
Set the Startup folder's path as expected in Windows 2000 or later.
If this folder exists, jump to the copying stage.
Report that the Startup folder can't be found.
Exit the batch script.
A label that can be jumped to.
Copy "MyApp" from the current folder (USB) to the Startup folder.
I don't want to take credit for Hand-E-Food's answer, but I figured out why his code didn't work and I can't reply to his answer, so here it is. Instead of using quotes around the %StartupFolder% variable in the Copy line, use them around the path for Set StartupFolder. Therefore, the code would be as follows.
#Echo Off
CD /D %~dp0
Set StartupFolder="%AppData%\Microsoft\Windows\Start Menu\Programs\Startup"
If Exist %StartupFolder% Goto :FoundStartup
Set StartupFolder="%UserProfile%\Start Menu\Programs\Startup"
If Exist %StartupFolder% Goto :FoundStartup
Echo Cannot find Startup folder.
Exit /B
:FoundStartup
Copy "MyApp" %StartupFolder%
The only reason I figured this out is because it wasn't doing anything for me either, so I tried removing the quotes around %StartupFolder% and that resulted in an error message that it couldn't find the folder, but at least I knew it was doing something at the end. Once I figured out that it was looking for the wrong folder because it thought the folder name stopped at the first space in its name, I simply added in the quotes and voila!
Try this (replace app.bat with whatever your actual app is called). This should work on Windows 2000 and up.
IF EXIST "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\*.*" COPY APP.BAT "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\"
IF EXIST "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\*.*" COPY APP.BAT "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\"