从 Web 浏览器(安全地)执行命令提示符

Executing a command prompt from the web browser (safely)

我只想知道如何在用户单击按钮时 git 将文件克隆到用户的桌面上。

可能吗?如果是,我可以采取什么措施来防止用户的任何输入和/或干预?

我真的,真的不希望有人侵入那里并导致人们 rm -rf / 他们的计算机。

虽然从浏览器访问命令行通常是 impossible/restricted,但您仍然可以从浏览器触发 git 回购克隆。

参见:

那是因为这些按钮是使用协议的链接(例如 x-github-client protocol) which register an action (here: "opening GitHub Desktop")

This is a protocol:

[HKEY_CLASSES_ROOT\x-github-client]
@="URL:x-github-client"
"URL Protocol"=""

This is a protocol handler:

[HKEY_CLASSES_ROOT\someapp\shell]
[HKEY_CLASSES_ROOT\someapp\shell\open]
[HKEY_CLASSES_ROOT\someapp\shell\open\command]
@=someapp.exe \"%1\"

This is what associates an app to a protocol:

[HKEY_LOCAL_MACHINE\SOFTWARE\SomeApp\Capabilities\UrlAssociations]
"x-github-client"="someapp"