home bbs files messages ]

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

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

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

   Message 67,177 of 68,980   
   Herbert Kleebauer to Paul Emmons   
   Re: Side effect of SETLOCAL   
   12 Apr 18 09:20:37   
   
   From: klee@unibwm.de   
      
   On 12.04.2018 01:19, Paul Emmons wrote:   
   > Consider this short demonstration batch file (running under Windows   
   > 7):   
   > ______________________________________   
   > setlocal   
   > Z:   
   > cd \TEMP   
   > dir   
   > ______________________________________   
   >   
   > The dir command lists the files of Z:\temp, proving that this is   
   > indeed the current directory of Z: at the time.   
   >   
   > However, after termination, the current directory of Z: reverts   
   > to whatever it was before execution.  Furthermore, if before   
   > execution the current drive and directory per the command prompt   
   > are for another drive, e.g. C:\, this situation is also restored.   
      
   Isn't this the only purpose of setlocal?   
      
   setlocal /?   
      
   Begins localization of environment changes in a batch file.  Environment   
   changes made after SETLOCAL has been issued are local to the batch file.   
   ENDLOCAL must be issued to restore the previous settings.  When the end   
   of a batch script is reached, an implied ENDLOCAL is executed for any   
   outstanding SETLOCAL commands issued by that batch script.   
      
   --- 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