如何使用SETLOCAL在批处理文件? [英] How do you use SETLOCAL in a batch file?

查看:139
本文介绍了如何使用SETLOCAL在批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 SETLOCAL 在批处理文件?我刚学的脚本,并希望它非常简单的术语向我解释说。

How do you use setlocal in a batch file? I am just learning scripting and would like it explained to me in very simple terms.

我有停止,并说,一个剧本<在这个时候它可能有一些做与不具有脚本中的任何 SETLOCAL 语句意外。

I have a script that stops and says < was unexpected at this time it may have something to do with not having any setlocal statements in the script.

推荐答案

您做的第一行 SETLOCAL 。本实施例是从下面的链接的文章:

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

最频繁使用的 SETLOCAL 是打开命令扩展,并允许变量延迟扩展:

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

SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

有关 SETLOCAL 更多信息请参见命令在微软的TechNet行参考

直接链接 SETLOCAL

这篇关于如何使用SETLOCAL在批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆