欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程是日常使用电脑方面的电脑常识:批处理高级命令:setlocal命令,学会并运用这些电脑常识,让你快速玩转电脑及互联网方面的知识,下面是详细的分享!
批处理高级命令:setlocal命令
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
以上就是关于批处理高级命令:setlocal命令的电脑常识分享,更多电脑教程请移步到>>电脑教程频道。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
