Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2012, 02:27 PM
prophetik music's Avatar
prophetik music prophetik music is offline
Bradley Burr, Thieves of Fate Director, Threshold of a Dream Director
Ganon (+8000)
OC ReMix Artist Profile
 
Join Date: Apr 2004
Location: Rochester, NY
need some batch help

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.

Code:
@ECHO OFF
CD C:\Documents and Settings\%USERNAME%\Local 

Settings\Temporary Internet Files
del /Q *eservices*.txt
pause
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.
__________________
|| how to computer: a faq on hardware || computer building || prophetikmusic.net ||
i write music. i fix and build computers. talk to me for information regarding either subject.
Reply With Quote
Sponsored Links

Please register to remove the above advertisement.
  #2  
Old 06-25-2012, 06:27 PM
hakstock's Avatar
hakstock hakstock is online now
Ivan Hakštok
Octorok (+200)
 
Join Date: Jan 2011
Location: Ston, Croatia
You'd need a for loop and searching for the string inside the file, something like:

file1.bat:

Code:
@echo off
cd C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Files
for /f %%a IN ('dir /b *.txt') do call file2.bat %%a
pause
file2.bat:

Code:
@echo off
findstr /m "eservices" %1
if %errorlevel% == 0
del /Q %1
pause
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.
Reply With Quote
  #3  
Old 06-25-2012, 06:41 PM
Kanthos's Avatar
Kanthos Kanthos is offline
Mike Chase
Luigi (+2000)
 
Join Date: Apr 2006
Location: Newmarket, Ontario, Canada
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.
Reply With Quote
  #4  
Old 06-25-2012, 08:34 PM
prophetik music's Avatar
prophetik music prophetik music is offline
Bradley Burr, Thieves of Fate Director, Threshold of a Dream Director
Ganon (+8000)
OC ReMix Artist Profile
 
Join Date: Apr 2004
Location: Rochester, NY
Quote:
Originally Posted by hakstock View Post
You'd need a for loop and searching for the string inside the file, something like:

file1.bat:

Code:
@echo off
cd C:\Documents and Settings\%USERNAME%\Local Settings\Temporary Internet Files
for /f %%a IN ('dir /b *.txt') do call file2.bat %%a
pause
file2.bat:

Code:
@echo off
findstr /m "eservices" %1
if %errorlevel% == 0
del /Q %1
pause
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.
__________________
|| how to computer: a faq on hardware || computer building || prophetikmusic.net ||
i write music. i fix and build computers. talk to me for information regarding either subject.
Reply With Quote
  #5  
Old 06-26-2012, 02:10 PM
prophetik music's Avatar
prophetik music prophetik music is offline
Bradley Burr, Thieves of Fate Director, Threshold of a Dream Director
Ganon (+8000)
OC ReMix Artist Profile
 
Join Date: Apr 2004
Location: Rochester, NY
getting closer!

Code:
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
find /i "eservices" < %%a > nul
if 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.
__________________
|| how to computer: a faq on hardware || computer building || prophetikmusic.net ||
i write music. i fix and build computers. talk to me for information regarding either subject.
Reply With Quote
  #6  
Old 06-26-2012, 06:28 PM
Kanthos's Avatar
Kanthos Kanthos is offline
Mike Chase
Luigi (+2000)
 
Join Date: Apr 2006
Location: Newmarket, Ontario, Canada
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.
Reply With Quote
  #7  
Old 06-26-2012, 09:59 PM
prophetik music's Avatar
prophetik music prophetik music is offline
Bradley Burr, Thieves of Fate Director, Threshold of a Dream Director
Ganon (+8000)
OC ReMix Artist Profile
 
Join Date: Apr 2004
Location: Rochester, NY
Quote:
Originally Posted by Kanthos View Post
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.
__________________
|| how to computer: a faq on hardware || computer building || prophetikmusic.net ||
i write music. i fix and build computers. talk to me for information regarding either subject.
Reply With Quote
  #8  
Old 06-27-2012, 12:59 PM
Kanthos's Avatar
Kanthos Kanthos is offline
Mike Chase
Luigi (+2000)
 
Join Date: Apr 2006
Location: Newmarket, Ontario, Canada
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).
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.