Command line tool to remove passwords in cred manager - windows

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.

Related

Remotely delete recent files history

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

Script to get Windows version and send it by email

I want to monitor version of Windows on all computers in a domain. So I want to create a .bat file that get the local Windows version and if possible send it via email using telnet command.
I never wrote a script in Windows. So it's difficult for me to start in this area. So any help will be appreciated.
for /f "skip=3 delims=\" %%A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %%A
Will give you a list of computernames. Put it in a file.
for /f "skip=3 delims=\" %%A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %%A >> Computername.txt
Then type to do turned on computers
wmic /node:#"Computername.txt" os get version /format:csv

Windows 2008 32bit. Having issue deleting files

I have an issue with deleting files from a command line. I can delete the file just fine through the Windows interface but i need to be able to run a script and delete multiple files. I am getting access denied and I am logged in as administrator. Any thoughts?
Here is the code
cd C:\views\IPGW_bld4_snap\direcpc
#echo off
setlocal enableextensions disabledelayedexpansion
for /f "delims=" %%a in ('cleartool ls -r -view_only') do del /q "%%a"
pause
Here is the output from cleartool ls -r -view_only
c:\views\IPGW_bld4_snap\direcpc>cleartool ls -r -view_only
.\noc\ipgateway\build\gen_html.vcproj
.\noc\ipgateway\build\libfcgi.vcproj
.\noc\ipgateway\build\libjson.vcproj
.\noc\ipgateway\ipgw\fcgicmdinf.c
.\noc\ipgateway\ipgw\fcgicmdinf.h
.\noc\ipgateway\ipgw\genconfightml.h
c:\views\IPGW_bld4_snap\direcpc>
In a ClearCase snapshot view, you can find file in read-only by default.
As mentioned in "Batch delete : Access is denied", try using del /F /Q
for /f "delims=" %%a in ('cleartool ls -r -view_only') do del /f /q "%%a"
You can couple that with "How to delete empty folders using windows command prompt?":
for /f "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"
That way, no empty folder is left behind after removing private files.

How do i delete all browsing data from all browser via command line?

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 ?

Find and delete desktop.ini files in every folder on a drive using a batch script

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

Resources