prophetik music Posted June 25, 2012 Share Posted June 25, 2012 i'm trying to delete a cookie with specific contents using a batch file. the cookie has the word "eservices" in it. every once and a while it goes nuts and i lose some functionality in my work browser, and i'm trying to get a quick one-click solution for that. here's what i've got. @ECHO OFFCD C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Filesdel /Q *eservices*.txtpause supposedly, this should delete any cookie with the word "eservices" in it, but i just get an error: "Could Not Find C:\Documents and Settings\bburr\Local Settings\Temporary Internet Files\*eservices*.txt" there's the problem - the cookie's name is some jumble of letters and numbers. i'm trying to delete a cookie that has the word IN it, not in the name. ideas, anyone? i can get you a copy of the cookie if you want. Quote Link to comment Share on other sites More sharing options...
Ivan Hakštok Posted June 25, 2012 Share Posted June 25, 2012 You'd need a for loop and searching for the string inside the file, something like: file1.bat: @echo offcd C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Filesfor /f %%a IN ('dir /b *.txt') do call file2.bat %%apause file2.bat: @echo offfindstr /m "eservices" %1if %errorlevel% == 0del /Q %1pause I've never done much programming in batch files, but it should go something like this, can't tell if it works because it returns a "file not found" on my pc. Quote Link to comment Share on other sites More sharing options...
Kanthos Posted June 25, 2012 Share Posted June 25, 2012 I'd copy the cookie in question plus a few others into a new folder and run the batch script in there to make sure it actually works, before letting it loose on your proper cookie folder. Quote Link to comment Share on other sites More sharing options...
prophetik music Posted June 25, 2012 Author Share Posted June 25, 2012 You'd need a for loop and searching for the string inside the file, something like:file1.bat: @echo offcd C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Filesfor /f %%a IN ('dir /b *.txt') do call file2.bat %%apause file2.bat: @echo offfindstr /m "eservices" %1if %errorlevel% == 0del /Q %1pause I've never done much programming in batch files, but it should go something like this, can't tell if it works because it returns a "file not found" on my pc. returns the same here =( i tested it on a folder that only contained a copy of the cookie and it didn't find it. Quote Link to comment Share on other sites More sharing options...
prophetik music Posted June 26, 2012 Author Share Posted June 26, 2012 getting closer! @echo offsetLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in ('dir/b *.txt') do (find /i "eservices" < %%a > nulif not errorlevel 1 echo del %%a)pause this one only runs locally, but it finds the file. unfortunately, it just prints "del [filename]" and then gives me the press any key dialog, rather than deleting it and then giving me the press any key dialog. can anyone tell me why this doesn't work? is this permissions or syntax? also, if i can get it to run on a folder rather than locally, that's even better. Quote Link to comment Share on other sites More sharing options...
Kanthos Posted June 26, 2012 Share Posted June 26, 2012 What happens if you remove the 'echo' in front of the del command? I don't know Windows batch files well enough to have coded you a solution, but I do know many of the commands, and echo is used to print stuff out to the screen. Quote Link to comment Share on other sites More sharing options...
prophetik music Posted June 26, 2012 Author Share Posted June 26, 2012 What happens if you remove the 'echo' in front of the del command? I don't know Windows batch files well enough to have coded you a solution, but I do know many of the commands, and echo is used to print stuff out to the screen. that does it =) i'll test it more tomorrow. only issue is that it appears to permanently delete it, rather than move it to the recycle bin (which would be preferable). time for more testing. Quote Link to comment Share on other sites More sharing options...
Kanthos Posted June 27, 2012 Share Posted June 27, 2012 Yeah, Windows doesn't offer a command-line method of sending stuff to the recycle bin; the command-line stuff is all inherited from DOS, which had no recycle bin. Take a look at this for a few ways to recycle from the command-line (the path to the recycle bin doesn't work on Windows 7, though there's probably some other path that would work). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.