简体   繁体   English

使用 VBScript,如何在 GitHub 的“Git Shell”中运行命令?

[英]Using VBScript, how can I run commands inside GitHub's 'Git Shell'?

I have a very specific question.我有一个非常具体的问题。 Details follow: I do not have Git installed.详细信息如下:我没有安装 Git。 I have only installed the GitHub desktop client (and the in-built Git it has).我只安装了 GitHub 桌面客户端(以及它的内置 Git)。 By default, they create a "Git Shell" desktop icon which launches your preferred shell (Cmd, Powershell, etc.) with git commands enabled.默认情况下,它们会创建一个“Git Shell”桌面图标,它会在启用 git 命令的情况下启动您首选的 shell(Cmd、Powershell 等)。 I don't know how this magical shortcut works!我不知道这个神奇的快捷方式是如何工作的! The problem is - I can invoke the shell by calling:问题是 - 我可以通过调用来调用 shell:

WshShell.Run("C:\Users\xx\AppData\Local\GitHub\GitHub.appref-ms --open-shell", 1, True)

- same as that desktop shortcut, but the above command opens the new command prompt and moves on. - 与桌面快捷方式相同,但上述命令会打开新的命令提示符并继续。

How can I execute commands in this newly launched window?如何在这个新启动的窗口中执行命令?

Thanks to crashmstr for his advice.感谢crashmstr的建议。

I installed Git for Windows.我为 Windows 安装了 Git。 It asked for my Github credential only on the first execution of git clone.它仅在第一次执行 git clone 时要求我提供 Github 凭据。 Now my VBS can open a normal command prompt and execute the git commands without prompting for credentials every-time.现在我的 VBS 可以打开一个普通的命令提示符并执行 git 命令,而无需每次都提示输入凭据。


This allows me to automate this particular solution but it leaves me wondering 'How can I execute commands on a command prompt window which was already open when my VBS execution began?'这让我可以自动化这个特定的解决方案,但它让我想知道“如何在我的 VBS 执行开始时已经打开的命令提示符窗口上执行命令?” But that's a different question altogether!但这完全是一个不同的问题! :) :)

Let's see if I can find a better solution than an unreliable approach to use AppActivate followed by SendKeys!让我们看看我是否能找到比使用 AppActivate 和 SendKeys 的不可靠方法更好的解决方案!

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

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