在Windows命令提示符下粘贴但不执行命令 [英] Paste but don't execute command in Windows command prompt

查看:124
本文介绍了在Windows命令提示符下粘贴但不执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是显示Windows命令提示符并在命令行上显示命令而不执行它。因此,如果我要显示命令 echo Hello ,我希望启动命令提示符并显示:

My target is to show the Windows command prompt and display a command on the command line without executing it. Therefore, if I want to display the command echo Hello, I want the command prompt to be started and display:

C:\Windows\System32> echo Hello _

...其中_是闪烁的光标等待为使用户按下键。

... where _ is the blinking cursor waiting for the user to press a key.

为此,我尝试创建Windows命令提示符可执行文件的快捷方式,该快捷方式的目标已更改到:
C:\Windows\System32\cmd.exe ...

To accomplish this, I've tried either to create a shortcut to the Windows command prompt executable, that has its "Target" changed to: C:\Windows\System32\cmd.exe ...

或包含以下内容的蝙蝠文件:

or a bat file containing:

cmd.exe / k ...

... / k代表:

... where /k stands for:


/ k:执行字符串指定的命令并继续

/k : Carries out the command specified by string and continues

这会使命令提示符继续存在,并且不会终止/ c开关的行为方式。

This makes the command prompt continue to live and not terminate the way the /c switch acts.

您知道如何实现此结果吗?

Any idea how to achieve this result?

推荐答案

使用 cmd 一个人。

Set sh = CreateObject("WScript.Shell")

sh.Run "%COMSPEC% /k @title MyCmd"
sh.AppActivate "MyCmd"
sh.SendKeys "echo Hello"

这篇关于在Windows命令提示符下粘贴但不执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆