gpt4 book ai didi

batch-file - 如何在批处理文件中使用 SETLOCAL?

转载 作者:行者123 更新时间:2023-12-03 07:51:14 24 4
gpt4 key购买 nike

你怎么用setlocal在批处理文件中?我只是在学习脚本,并希望用非常简单的术语向我解释。

我有一个脚本停止并说 < was unexpected at this time这可能与没有任何 setlocal 有关。脚本中的语句。

最佳答案

你做第一行 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

使用频率最高的 SETLOCAL是打开命令扩展并允许变量的延迟扩展:
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

有关 SETLOCAL 的更多信息见 Command Line Reference在 Microsoft TechNet。

直接链接到 Setlocal

关于batch-file - 如何在批处理文件中使用 SETLOCAL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13704223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com