How do you use SETLOCAL in a batch file?

You make the first line SETLOCAL. This example is from the linked article below:

rem *******Begin Comment**************
rem This program starts the superapp batch program on the network,
rem directs the output to a file, and displays the file
rem in Notepad.
rem *******End Comment**************
@echo off
setlocal
path=g:\programs\superapp;%path%
call superapp>c:\superapp.out
endlocal
start notepad c:\superapp.out

The most frequent use of SETLOCAL is to turn on command extensions and allow delayed expansion of variables:

SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

For more info on SETLOCAL see the Command Line Reference at Microsoft TechNet.

Direct link to Setlocal

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)