Computer Hope

Software => Computer programming => Topic started by: bminster on September 23, 2020, 11:43:02 AM

Title: Batch script help
Post by: bminster on September 23, 2020, 11:43:02 AM
I am working on a batch script the clear all the saved credentials on a Windows 10 machine.  I got the script off the web, but it doesn't fully work. 

@echo off
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
echo All done
pause

The script calls for all the credentials in Windows using cmdkey and dumps it to a file.  Then it does a findstr to parse the file.  The results that I am having problems with are the ones with spaces in them.

Example: Target: LegacyGeneric:target=Adobe App Prefetched Info (UGhvdG9zaG9wMXt9MjAxODA3MjAwMQ)(Part2)

The script returns only the word Adobe when I need it to return the entire string after target=.  Any help would be appreciated.
Title: Re: Batch script help
Post by: Hackoo on September 24, 2020, 01:05:40 AM
Hi  ;)
What did you get with this batch ?
Code: [Select]
@echo off
FOR /F "tokens=2 delims==" %%H IN ('cmdkey /list ^| findstr /I "target"') DO echo "%%~H"
pause