简体   繁体   English

“cd”在第一次执行 Windows 批处理文件时不起作用

[英]"cd" doesn't work in the first execution of the Windows batch file

I have a simple batch that works well every time:我有一个简单的批次,每次都运行良好:

@echo off

set @TRUNK_DIR=%cd%

echo %@TRUNK_DIR%

I have the same lines as the first lines of a larger batch, but when I open a new prompt the TRUNK_DIR variable is empty on first run batch and gives error.我的行与较大批次的第一行相同,但是当我打开新提示时,TRUNK_DIR 变量在第一次运行批次时为空并给出错误。 In this batch I put a new echo %@TRUNK_DIR% in the end of file and @TRUNK_DIR continue empty.在这批中,我在文件末尾放置了一个新的 echo %@TRUNK_DIR% 并且 @TRUNK_DIR 继续为空。

In the other plays batch works well.在其他戏剧中,批处理效果很好。

What's happened?发生了什么? I don't have any idea.我不知道。

This program should work, so my only recommendation would be to try running the file;这个程序应该可以工作,所以我唯一的建议是尝试运行该文件; only without the @ symbol.只有没有@符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM