Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Does anyone know how to do this, I was thinking along the lines setting a value of 1 initially in a separate count.txt file, then every time my prog.bat ran telling it to read count.txt and add 1 to the existing value. Then to continually check if the value goes over 5 and delete the prog.bat.
I have tried to do this myself but don't know the proper code, can anyone help - Thank's

Just send me an e-mail or give me your e-mail, it might take me a bit and by then the message will be on the 5th page if not more, hehe :)

This one will delete itself
after the 5th run. Doskey must
be in the path (or running).
:: delme5.bat
:: deletes self after the fifth time run
@echo off
ECHO %0 |FIND.EXE ":\" >nul
IF errorlevel=1 ECHO Enter complete path to %0
IF errorlevel=1 GOTO end
:: This example counts up to five and will echo a message to the
:: screen every fifth time it is run.
SET cnt=:check
SET cnt=%cnt%*
MEM/C |FIND.EXE "DOSKEY" >nul
IF not errorlevel=1 GOTO start
IF "%cnt%"=="**" GOTO nodoskey
LH DOSKEY.COM
GOTO check:start
SET cnt=
SET src=
IF exist %0.bat SET src=%0.bat
IF "%src%"=="" IF exist %0 SET src=%0
IF "%src%"=="" ECHO "%0" must exist as entered
IF "%src%"=="" GOTO end
:: * your code for every run goes here *SET key=::#
ECHO %key%# Do not remove or change this line!>> %src%:: Change the 5's below to set the counter.
FIND/C "%key%#" nul %Set counter here%
IF errorlevel=1 GOTO end:clear
FIND/V "%key%#" %src%
:: ECHO %src% has run 5 times:: *your code for run 5 goes here*
GOTO delete
GOTO end:nodoskey
SET cnt=
ECHO. unable to load doskey.com
GOTO end:delete
SET key=
ECHO. Deleting %src%
::doskey delme=del %src% $t exit $t set src=$t doskey delme=$t cls
::echo delme | command /k:end
SET key=
SET src=

Try again. Watch for wrapped lines.
Note: You must uncomment the lines in the
delete module to do the actual deleting.:: delme5.bat
:: deletes self after the fifth time run
@echo off
ECHO %0 |FIND.EXE ":\" >nul
IF errorlevel=1 ECHO Enter complete path to %0
IF errorlevel=1 GOTO end
:: This example counts up to five and will echo a message to the
:: screen every fifth time it is run.
SET cnt=:check
SET cnt=%cnt%*
MEM/C |FIND.EXE "DOSKEY" >nul
IF not errorlevel=1 GOTO start
IF "%cnt%"=="**" GOTO nodoskey
LH DOSKEY.COM
GOTO check:start
SET cnt=
SET src=
IF exist %0.bat SET src=%0.bat
IF "%src%"=="" IF exist %0 SET src=%0
IF "%src%"=="" ECHO "%0" must exist as entered
IF "%src%"=="" GOTO end
:: * your code for every run goes here *SET key=::#
ECHO %key%# Do not remove or change this line!>> %src%:: Change the 5's below to set the counter.
FIND/C "%key%#" nul %Set counter here%
IF errorlevel=1 GOTO end:clear
FIND/V "%key%#" %src%
:: ECHO %src% has run 5 times:: *your code for run 5 goes here*
GOTO delete
GOTO end:nodoskey
SET cnt=
ECHO. unable to load doskey.com
GOTO end:delete
SET key=
ECHO. Deleting %src%
::doskey delme=del %src% $t exit $t set src=$t doskey delme=$t cls
::echo delme | command /k:end
SET key=
SET src=

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |