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,180 of 68,980   
   npocmaka to All   
   Re: Side effect of SETLOCAL   
   12 Apr 18 09:41:28   
   
   From: npocmaka@gmail.com   
      
   On Thursday, April 12, 2018 at 4:52:46 PM UTC+1, JJ wrote:   
   > On Thu, 12 Apr 2018 09:20:37 +0200, Herbert Kleebauer wrote:   
   > > 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.   
   >   
   > I'm aware that SETLOCAL does affect the working directory, but I concur with   
   > Paul Emmons.   
   >   
   > SETLOCAL's help only mention "environment". For those who are new to CMD,   
   > would think that it means the environment variables. For those who are   
   > already familiar with CMD, may have already know this and the "environment"   
   > in that context, means the command prompt (or terminal) environment.   
   >   
   > However, this is not true (at least on Windows 7 version of CMD). SETLOCAL   
   > does not affect the states of: ECHO, DPATH, VERIFY, color, and title of the   
   > console window. So IMO, SETLOCAL's help is not being clear enough.   
      
   DPATH and PATH are affected.KEYS is not.MODE is not.   
      
   --- 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