I want to delete the recent files history that can be found when you open File Explorer (in Windows 10). I want to do it using cmd, so that I can do it in all the computers on my network without going one by one
#echo off
del /F /Q %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\*
del /F /Q %APPDATA%\Microsoft\Windows\Recent\CustomDestinations\*
del /F /Q %APPDATA%\Microsoft\Windows\Recent\*
taskkill /f /im explorer.exe
start explorer.exe
Related
I need to write a windows bat program to delete particular folders with naming pattern scoped_dir45666,scoped_dir45667 ...so on (for example)(including contents)
with batch program. For that I am using below code:
#echo off
Taskkill /IM chromedriver.exe /F
Taskkill /IM chrome.exe /F
cd /D %temp%
for /d %%D in (*) do rd /s /q "%%D"
del /f /q *
but its deleting everything under %temp% causing system issues...(its screwing some os files also I guess)
I need to delete all directories names starting with scoped_dirxxxxx (scoped_dir*) under %temp% directory of my user can some one advise how to modify above code to delete only folders name starting with scoped_dir in %temp% folder
Just add the prefix in front of the wildcard:
for /d %%D in (scoped_dir*) do rd /s /q "%%D"
If you only want to delete these directories, you should also get rid of the last line del /f /q * as it will delete all files on the root level of your %TEMP% directory.
The first part of my script:
#echo off
mode 34,18
color f0
del /s /q /f unsorted_frt.txt >nul 2>nul
del /s /q /f output_frt.txt >nul 2>nul
del /s /q /f frt.txt >nul 2>nul
del /s /q /f datas_futuros_rede_tan.txt >nul 2>nul
del /s /q /f datas_futuros_rede_tan.csv >nul 2>nul
del /s /q /f c:\datas_futuros_rede_tan.csv >nul 2>nul
(etc.)
Using Windows 7 it succeeds. But if the files to delete don't exist, the .bat file ignored this and continued anyway. I upgraded to Windows 10 and now, if the files to delete don't exist, the script fails entirely.
I need the script to continue despite this. How can I make that work on Windows 10? This is what it currently looks like:
It stops at this screen. If I delete this first part of the script, the rest runs normally.
Answer previously posted on question:
The problem is occurring in this line del /s /q /f c:\datas_futuros_rede_tan.csv >nul 2>nul So i changed it to del /s /q /f "c:\datas_futuros_rede_tan.csv" >nul 2>nul So, after more or less 2 minutes stopped in the same screen (like the image above), it starts to keep going.
It is usually a good idea to test whether or not the file exists before deleting it.
IF EXIST "unsorted_frt.txt" DO (DEL "unsorted.txt")
A FOR loop can help in deleting a large list of files. This list would presume that all files except the last one are in the current working directory. If the file names contain SPACE or other special characters, then they need to be quoted.
SET FILE_LIST=^
unsorted_frt.txt ^
output_frt.txt ^
frt.txt ^
datas_futuros_rede_tan.txt ^
datas_futuros_rede_tan.csv ^
c:\datas_futuros_rede_tan.csv
FOR %%f IN (%FILE_LIST%) DO (
IF EXIST "%%~f" DO (DEL "%%~f" >NUL 2>NUL)
)
I found a post on superuser to delete all creds from windows credential manager.
https://superuser.com/questions/689456/what-is-the-windows-7-command-line-to-remove-all-remember-passwords-in-credentia
Code:
echo on
cmdkey.exe /list > "%TEMP%\List.txt"
findstr.exe Target "%TEMP%\List.txt" > "%TEMP%\tokensonly.txt"
FOR /F "tokens=1,2 delims= " %%G IN (%TEMP%\tokensonly.txt) DO cmdkey.exe /delete:%%H
del "%TEMP%\List.txt" /s /f /q
del "%TEMP%\tokensonly.txt" /s /f /q
pause
This works on windows 7 but does not work on windows 10 and i'm not able to figure out why. cmdkey.exe /list still functions in windows 10 and it still pipes the file so i assuming the issue is with findstr.exe for an issue with the for loop in the batch file but I can't figure out what the problem is.
I created a batch script to delete all browsing data from all browser via command line.
But it fails and doesn't clear all data.
It only deletes all the chrome data.
IE and firefox data isnt being deleted.
This works fine
for chrome:
set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data
del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"
for firefox
set DataDir=C:\Users\%USERNAME%\AppData\Local\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
it does not delete all data.
for IE
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
This is also not working.
Please help me.
i am using windows 8.1 IE 11.
Is any other way to do this easily.
via command line.
So i tried the commands for firefox and IE11 both work for me. Are you running the script as administrator?
I changed the firefox command abit see below:
set DataDir=%loaclappdata%\Mozilla\Firefox\Profiles
del /q /s /f "%DataDir%"
rd /s /q "%DataDir%"
for /d %%x in (%appdata%\Mozilla\Firefox\Profiles\*) do del /q /s /f %%x\*sqlite
As an alternitive you could use CCleaner command-line the command below will run ccleaner and clean using your default settings then close the program.
Cd "C:\Program Files\CCleaner"
ccleaner.exe /Cleaner /AUTO
You will have to change this command depending on if you use 32bit or 64bit windows
Are you planing on using this on a network ?
I want to find and delete every desktop.ini and Recycle Bin.BIN file on a network drive, H:, using a windows batch file. I currently have this:
#echo About to delete all desktop.ini and Recycle Bin.BIN files from H:, press Ctrl+C to cancel or Enter to continue.
#pause
#H:
#for /f "usebackq" %%i in (`dir /s /b /x /A:H ^| find "desktop.ini"`) do del /A:H "%%i"
#for /f "usebackq" %%i in (`dir /s /b /x /A:RH ^| find "Recycle Bin.BIN"`) do del /A:RH "%%i"
#echo Deleting complete, press any key to exit.
#pause
Which works but for any file in a sub-folder with a space in the name it fails with a "cannot find file" error. Any suggestions how to fix that?
solution that worked for me was
create bat file "delete_all_desktop_ini.bat"
with
del /s /q /f /a ".\desktop.ini"
put it in a folder and run it
it will delete all desktop inis in current directory and sub directories of this file.
i put it in a project folder that is in google drive
Give this a test:
I've altered the recycle bin name to what I see here in Windows 8.
The name changes with different versions of Windows.
#echo off
del /s /q /f /a "h:\desktop.ini"
del /s /q /f /a "h:\$Recycle.Bin\*.*"
The problem occurs because by default space is a delimiter for the for command, but you can change this using the delims option. If you pick a character that won't ever appear in a file path then it should work fine:
#echo About to delete all desktop.ini and Recycle Bin.BIN files from H:, press Ctrl+C to cancel or Enter to continue.
#pause
#H:
#for /f "usebackq delims=|" %%i in (`dir /s /b /x /A:H ^| find "desktop.ini"`) do del /A:H "%%i"
#for /f "usebackq delims=|" %%i in (`dir /s /b /x /A:RH ^| find "Recycle Bin.BIN"`) do del /A:RH "%%i"
#echo Deleting complete, press any key to exit.
#pause
for /r "H:\" %%a in (desktop.ini $Recycle.Bin) do if exist "%%~fa" echo del /f "%%~fa"
Try it, to make it working remove echo from the script.
del /s /q /f /a ".\desktop.ini"
it should works as charm
save file .bat
put it in any folder
it will delete ini files in folders and sub folders