【问题标题】:Close cmd window after Git command in batch script在批处理脚本中的 Git 命令后关闭 cmd 窗口
【发布时间】:2017-01-13 14:51:09
【问题描述】:

我编写了一个简短的批处理脚本 (Windows 7) 来捆绑 Git 存储库并将副本保存在网络驱动器上:

@ECHO OFF
cd /D E:/mypath/myrepo.git
start "Window title" "C:\pathto\Git\git-cmd.exe" git bundle create X:/outpath/name.bundle --branches --tags

这按预期工作,但是,我希望窗口在完成后关闭。我试过exit,但窗口只是返回到cd指定的目录,并保持打开状态。

如何关闭窗口? (我在其他帖子中看到了很多推测性的答案,我在问在这种情况下我如何才能真正/实际上关闭窗口)

【问题讨论】:

    标签: git batch-file windows-7


    【解决方案1】:

    尝试:

    start "Window title" "C:\pathto\Git\git-cmd.exe" git bundle create X:/outpath/name.bundle --branches --tags ^&exit 
    

    要退出控制台当然需要exit 命令。要在一行上执行两个命令,您通常使用 ampersand 。但在这种情况下,您希望退出作为 START 命令的一部分,但在启动后不执行,因此您 escape & 带有插入符号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 2018-08-20
      相关资源
      最近更新 更多