Unable to remove folder with CMD - windows

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

Related

How to delete the contents of temp folder in remote machine through command

I have a requirement where i need to delete the contents of the temp folder on number of remote windows machines.
i tried below wmic command to delete
WMIC /node:...** /user:xxxx /password:xxxx path cim_datafile WHERE "path='%Winddir%\temp*.tmp' AND Extension ='tmp'" delete**
But it throws an error saying
ERROR:
Description = The RPC server is unavailable.
Please suggest me a way to delete temp folder contents on remote machine.
Most simple way - if you're not strictly forced to use WMI, you can do that with psexec:
PsExec.exe \\<computer> cmd /c "rmdir /s /q %windir%\temp\"
or, if you're not logged into domain admin or global workstations admin account -
PsExec.exe -u <user> -p <password> \\<computer> cmd /c "rmdir /s /q %windir%\temp\"
If should not completely delete the folder since Windows keeps some files open and locked inside it, but anything not read-only or locked would be deleted, both files and folders.
Then, to do this with a list of computers, just use a cmd file like this (list.txt contains just computer names/ips, without \:
for /F %%s in (list.txt) do (
echo %%s
start "" /min PsExec.exe \\%%s cmd /c "rmdir /s /q %windir%\temp\"
)
Start command makes all psexec processes run in parallel and minimized so you don't have to wait for each computer to finish before starting another
psexec.exe is a part of sysinternals package from M. Russinovich, I'd like to leave a direct link but don't know if it's permitted or not.
I think it should be able to connect to remote pcs if you have access to file shares and remote computer management (and admin rights of course)

cmd/bat file not running properly if ran as administrator from external drive

I have made a simple batch file to copy a file from its folder to Windows 10 Program Files folder. The problem is if I run the file with right click run as administrator from any drive in the main hard disk it runs properly. But if I run it from an external USB drive with right click run as administrator, CMD gets flashed for a second but it does not even pause. Neither the file gets copied. If I run cmd file from an already open cmd prompt with admin rights, it runs properly. If I run double click cmd file and run without administrator, the CMD stays open and says Access is Denied which should be for C://Program Files
Below is the code
pushd %~dp0
MD "C:\Program Files\Example Folder"
ROBOCOPY . "C:\Program Files\Example Folder" "Example File.ext"
popd
PAUSE
I have tried XCOPY and COPY as well.

How can I delete a folder using CMD utitilty in Windows XP?

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.

Impossible to delete folder Windows 7

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.

Cannot fully delete ProgramData from Windows 8 installation within WinPE

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.

Resources