Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch script help  (Read 54691 times)

0 Members and 1 Guest are viewing this topic.

bminster

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 10
    Batch script help
    « 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.

    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: Batch script help
    « Reply #1 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