【问题标题】:how to inject code with a batch into a batch that has existing code [closed]如何将带有批处理的代码注入具有现有代码的批处理[关闭]
【发布时间】:2021-02-25 04:35:59
【问题描述】:

我是否将其转换为 txt 文件?如何在其他行之间注入新行?我正在尝试将钱包地址注入一个简单的挖矿批处理文件,而无需事先打开它。

几乎是实现矿机自动化以实现完全自给自足的最后一步。

如果有人有这样做的任何方法,请详细描述或展示一个例子,因为我是自学成才的,并且在发布之前超出预期的项目超出了我的头脑,哈哈

【问题讨论】:

    标签: python html batch-file helper


    【解决方案1】:

    一种选择是使用设置文件,如果该文件不存在,例如在第一次运行时,则改为创建它:

    @echo off
    
    setlocal enabledelayedexpansion
    
    if not exist example_settings.cmd (
        echo Creating settings file
        rem Prepare a helper batch file to store the settings
        echo|set /p="set _key=">example_settings.cmd
    
        rem Imagine this "echo Example" is instead a command that returns a new value
        echo Example>>example_settings.cmd
    )
    
    call example_settings.cmd
    echo The setting is %_key%
    

    这将使用密钥集创建一个设置文件,并在后续运行中使用帮助程序批处理文件中的该密钥,而不是尝试创建一个新密钥。

    【讨论】:

      【解决方案2】:

      我会用 f.readlines() 读入整个文件,这样你就可以得到一个字符串列表(每个字符串代表文件中的一行),编写一些逻辑来确定新字符串应该放在哪里,然后然后将其重新写入文件。

      【讨论】:

        猜你喜欢
        • 2020-09-13
        • 1970-01-01
        • 1970-01-01
        • 2021-10-24
        • 1970-01-01
        • 2017-08-02
        • 1970-01-01
        • 2021-12-10
        • 2015-02-24
        相关资源
        最近更新 更多