home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 40,696 of 42,547   
   blinkingblythe01@gmail.com to All   
   Enviroment variables not staying after b   
   24 Jul 13 22:06:04   
   
    Under Dosbox and MsDos, the counter works fine. Under windows XP's command   
   com, the counter refuses to go past 1. The batch file is not keeping the   
   "count" variable updated once it leaves and a look at set shows the count   
   variable isn't even in the    
   environment. I'm not using command /c or anything   
   to call the file, just the batch files name. Does anyone know what is going on   
   here?   
      
      
      
   @echo off    
      
   rem Here is one application for using the counter if you want to limit   
      
   rem how many times someone can access a program    
      
   rem (note this line must be placed right at the beginning of the file)    
      
   rem You also have to put a line like this in your AUTOEXEC.bat    
      
   rem set lock=unlocked    
      
   rem because if it reads all 4 variables as blank it will think that the    
      
   rem limit is set at null and it wont work. also after 99 the file will put    
      
   rem a 0 before the 2nd digit so you may have to reset the limit and    
      
   rem include the 0. for example 01. If it is double digit, you do not    
      
   rem have to change anything.    
      
    rem remember not to include rem in this line.    
      
    rem if "%lock2%%lock%"=="%count2%%count%" goto locked    
      
    rem This is a Batch counter. Every time this file runs it will count up    
      
    rem one number.    
      
   if "%count%"=="" goto 0   
      
   if "%count%"=="0" goto 0    
      
      
   if "%count%"=="1" goto 1    
      
   if "%count%"=="2" goto 2    
      
   if "%count%"=="3" goto 3    
      
   if "%count%"=="4" goto 4    
      
   if "%count%"=="5" goto 5    
      
   if "%count%"=="6" goto 6    
      
   if "%count%"=="7" goto 7    
      
   if "%count%"=="8" goto 8    
      
   if "%count%"=="9" goto 9    
      
   goto end   
      
    :0    
      
   set count=1    
      
    goto end    
      
    :1    
      
   set count=2    
      
    goto end    
      
    :2    
      
   set count=3    
      
    goto end    
      
    :3    
      
   set count=4    
      
    goto end    
      
    :4    
      
   set count=5    
      
    goto end    
      
    :5    
      
   set count=6    
      
    goto end    
      
    :6    
      
   set count=7    
      
    goto end    
      
    :7    
      
   set count=8    
      
    goto end    
      
    :8    
      
   set count=9    
      
    goto end    
      
    :9    
      
   set count=0    
      
   if "%count2%"=="" goto 11    
      
   if "%count2%"=="1" goto 12    
      
   if "%count2%"=="2" goto 13    
      
   if "%count2%"=="3" goto 14    
      
   if "%count2%"=="4" goto 15    
      
   if "%count2%"=="5" goto 16    
      
   if "%count2%"=="6" goto 17    
      
   if "%count2%"=="7" goto 18    
      
   if "%count2%"=="8" goto 19    
      
   if "%count2%"=="9" goto 20    
      
    :11    
      
   set count2=1    
      
    goto end    
      
    :12    
      
   set count2=2    
      
    goto end    
      
    :13    
      
   set count2=3    
      
    goto end    
      
    :14    
      
   set count2=4    
      
    goto end    
      
    :15    
      
   set count2=5    
      
    goto end    
      
    :16    
      
   set count2=6    
      
    goto end    
      
    :17    
      
   set count2=7    
      
    goto end    
      
    :18    
      
   set count2=8    
      
    goto end    
      
    :19    
      
   set count2=9    
      
    :20    
      
   set count2=0    
      
    goto end    
      
    :locked    
      
    echo Sorry, You cannot access this file after %count2%%count% times    
      
    goto end    
      
    :end    
      
    echo %count2%%count%    
      
    rem To set the lock: Just type these 2 lines:    
      
    rem set lock=n where n is the first digit in the number    
      
    rem set lock2=n where n is the second digit in the number    
      
    rem if you are setting only a 1 digit number type    
      
    rem set lock=n    
      
    rem set lock=   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca