八亿网

批处理高级命令:setlocal命令

时间:2015-12-24 来源:网络 作者:win8e 阅读:122

  setlocal命令用于启动批处理文件中环境变量的本地化。本地化将持续到出现匹配的endlocal命令或者到达批处理文件结尾为止。

  语法:

  setlocal {enableextension丨disableextensions}{enabledelayedexpansion丨disabledelayedexpansion}

  参数:

  enableextension

  启用命令扩展,直到出现匹配的endlocal命令,无论setlocal命令之前的设置如何。

  disableextensions

  禁用命令扩展,直到出现匹配的endlocal命令,无论setlocal命令之前的设置如何。

  enabledelayedexpansion

  启用延迟的环境变量扩展,直到出现匹配的endlocal命令,无论setlocal命令之前的设置如何。

  disabledelayedexpansion

  禁用延迟的环境变量扩展,直到出现匹配的endlocal命令,无论setlocal命令之前的设置如何。

  举例:

  可以在批处理文件中本地化环境变量,代码如下:

  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

本站所有内容均旨在传递信息,我们尽可能保证信息的准确性。如有错误或侵犯了您的权益,请联系我们。

电脑知识 · 相关内容