batch-file - 使用批处理文件,如何写入位置存储在变量中的文件?
问题描述
我想创建一个名为“server.cfg”的文件并将其放在路径存储在变量中的位置。我编写了下面的代码来尝试完成此操作,但脚本没有使用变量,而是在与脚本相同的文件夹中创建了一个名为“server”的文件。
:: Set the data variable with the folder name where server.cfg file will be (check the example)
:: example SET data=server-dataV1
SET data= server-dataV1.2
SET server = %data%\resources\server.cfg
echo # Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only. >> server
echo endpoint_add_tcp "0.0.0.0:30120" >> server
echo endpoint_add_udp "0.0.0.0:30120" >> server
echo >> server
echo set mysql_connection_string "mysql://root:12345@localhost/es_extendedv1?charset=utf8mb4" >> server
echo set mysql_slow_query_warning 200000 >> server
解决方案
不幸的是,目前尚不清楚您要达到的目标,所以这是我最好的猜测。
@Rem Set the data variable with the folder name where server.cfg file will be (check the example)
@Rem Example: Set "data=server-dataV1"
@Set "data=server-dataV1.2"
@Set "server=%data%\resources\server.cfg"
@(
Echo # Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
Echo endpoint_add_tcp "0.0.0.0:30120"
Echo endpoint_add_udp "0.0.0.0:30120"
Echo=
Echo set mysql_connection_string "mysql://root:12345@localhost/es_extendedv1?charset=utf8mb4"
Echo set mysql_slow_query_warning 200000
) 1> "%server%"
推荐阅读
- python - 通过python加入服务器时,是否有绕过discord的可疑活动屏幕?
- python-3.x - ImportError:Debian 操作系统中没有名为 numpy 的模块
- ios - 在“优化 Mac 界面”模式下使用 Catalyst 构建应用程序时如何设置按钮标题颜色
- javascript - 如何解密加密的 JavaScript 代码?
- python - 包目录火币不存在
- javascript - 返回并存储来自异步函数的承诺结果
- mysql - 如何在 SQL 4.9.5 中替换 WITH 子句。我在版本 8 中使用它,但我的服务器不支持它
- python - 如何让我的函数仅在端点的特定变量发生变化时调用?(Python)
- pine-script - Pine 编辑器获取特定栏的真实范围
- html - 如何让我的按钮在 jquery 中多次工作?