批处理高级命令:setlocal命令

 
批处理高级命令:setlocal命令
2016-09-21 06:56:21 /故事大全

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:programssuperapp;%path%

call superapp>c:superapp.out

endlocal

start notepad c:superapp.out

所属专题:
如果您觉得本文或图片不错,请把它分享给您的朋友吧!

 
搜索
 
 
广告
 
 
广告
 
故事大全
 
版权所有- © 2012-2015 · 故事大全 SITEMAP站点地图 Power by flip clock online手机看故事 站点地图 Power by flip clock online