Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 将环境变量从一个批处理文件追加到另一个批处理文件_Batch File_Cmd_Environment Variables - Fatal编程技术网

Batch file 将环境变量从一个批处理文件追加到另一个批处理文件

Batch file 将环境变量从一个批处理文件追加到另一个批处理文件,batch-file,cmd,environment-variables,Batch File,Cmd,Environment Variables,这是我正在处理的批处理文件中的一行代码 echo %systemroot% >> untitled.bat 它的任务是将文本%systemroot%附加到另一个名为untitled.bat的批处理文件中。 当我用记事本打开untitled.bat文件以查看代码时,它显示为C:\Windows。 这是有道理的,因为这是我的%systemroot%,但我的问题是我希望将代码作为%systemroot%而不是C:\Windows写入untitled.bat文件 有人知道这是怎么可能的吗?

这是我正在处理的批处理文件中的一行代码

echo %systemroot% >> untitled.bat
它的任务是将文本%systemroot%附加到另一个名为untitled.bat的批处理文件中。 当我用记事本打开untitled.bat文件以查看代码时,它显示为C:\Windows。 这是有道理的,因为这是我的%systemroot%,但我的问题是我希望将代码作为%systemroot%而不是C:\Windows写入untitled.bat文件


有人知道这是怎么可能的吗?

这行代码对我来说很有用:

echo %%systemroot%% >> untitled.bat

您是否尝试使用引号,即echo%systemroot%>>untitled.bat?