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 41,514 of 42,547   
   Todd Vargo to David Jenkins   
   Re: Question about batch labels   
   30 Oct 16 15:08:55   
   
   From: tlvargo@sbcglobal.netz   
      
   On 10/28/2016 8:31 AM, David Jenkins wrote:   
   > I am developing a script with a Windows batch file.  The portion I'm working   
   on right now is to take the hostname of the workstation and set it to a   
   variable named current.  We are only running this script on a certain group of   
   machines with known    
   names, so that another batch file can be called to perform the task on the   
   devices associated with that.  My problem is that I am continuing to get the   
   "The system cannot find the batch label specified."  I have seen a few   
   potential solutions for    
   specific scenarios elsewhere, but I was wondering if I could get a brief   
   assist on this since the labels are somewhat random.   
   >   
   > Here is a portion of my code.  I've left my latest attempt at "if   
   errorlevel..." since none of them have seemed to work.   
   >   
   >   
   > ================================================   
   > echo off   
   > cls   
   > hostname>D:\Install\Script\Carts\name.dat   
   > set /p current= pause   
   > goto %current%   
   > if errorlevel 1 (   
   > goto :gotaproblem   
   > )   
   > goto :eof   
   >   
   >   
   > :computerabcd   
   > start computerabcd_BS.bat /K   
   > exit   
   > goto :eof   
   >   
   > :computerabce   
   > start computerabce_BS.bat /K   
   > :exit   
   > goto :eof   
   >   
   > :60more_computerabc_   
   > start 60morecomputerabc__BS.bat /K   
   > :exit   
   > goto :eof   
   >   
   > :gotaproblem   
   > echo off   
   > cls   
   > echo.   
   > echo.   
   > echo.   
   > echo This workstation is not named correctly or cannot accept this update.   
   Please contact Name of Person for resolution.   
   > echo.   
   > echo Please press a key to close.   
   > echo.   
   > echo.   
   > pause   
   > exit   
   >   
   > ===============================================   
   >   
   >   
   >   
   > Any assistance would be much appreciated.   
   >   
      
   On second thought, here is another way.   
      
   Place these two lines above your "goto %current%" line.   
      
   find /i "%current%"<"%~f0">nul   
   if errorlevel 1 goto :gotaproblem   
      
      
   For trouble shooting purposes, I would add the following line in your   
   :gotaproblem section.   
      
   echo CRITICAL_ERROR: %current%   
      
   Also, this all assumes that %current% contains a leading colon. If not,   
   you need to add it to your "goto %current%" line.   
      
   goto :%current%   
      
   --   
   Todd Vargo   
   (Post questions to group only. Remove "z" to email personal messages)   
      
   --- 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