在 Visual Studio 中执行 dos 命令的交互式窗口
我知道使用外部工具选项我可以运行批处理脚本或 cmd 提示符。但这是我需要做的,
我希望能够在 Visual Studio 中调用 dos 提示符,它必须是交互式的。这样我就不会离开 Visual Studio,并且可以在其中运行我的所有 dos 命令。是否可以?或者我可以扩展命令窗口并捕获键入的命令并使用我的自定义代码处理它们吗?
谢谢
I know using External Tools options i can run a batch script or a cmd prompt. But here is what i need to do
I want to be able to call a dos prompt inside visual studio, which must be interactive. That way i won't be outside visual studio and can run all my dos commands in it. Is it possible? Or can i extend the command window and capture the commands which are typed and process them using my custom code?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Tools.Shell 命令可能适合您。您可以使用 /c 开关指定可执行文件的输出显示在命令窗口中。然后,您使用 /C 开关调用 cmd.exe,该开关指示它在完成命令后关闭。例如,如果您键入:
这会将输出打印到命令窗口。不幸的是,与输出不同的是,输入不起作用。因此,如果您输入:
提示将不会等待您的输入(按某个键)。
如果这对您来说没问题,您甚至可以为其中的大部分定义一个别名。例如,您定义别名 sh for Tools.Shell /c cmd.exe /C:
然后您只需按如下方式使用它:
There's the Tools.Shell command which may work for you. You use the /c switch to specify that the output for the executable is displayed in the Command window. Then you call cmd.exe with /C switch which instructs it to close after finishing the command. For example if you type:
This will print the output to the Command window. Unfortunately, unlike the output, the input doesn't work. So if you type:
The prompt will not wait for your input (pressing a key).
If that's OK for you, you can even define an alias for most of this. For example you define alias sh for Tools.Shell /c cmd.exe /C:
Then you simply use it as follows:
如果安装 NuGet,则会将程序包管理器控制台添加到 Visual Studio,这本质上是一个 Powershell 命令提示符。应该有一些方法可以通过 Powershell 完成大多数 DOS 操作,并且还可以提供更多功能。
If you install NuGet, then it adds Package Manager Console to Visual Studio which is essentially a Powershell command prompt. There should be ways of doing most DOS stuff via Powershell and heaps more functionality as well.
不完全是您所要求的,但我认为您可以使用 StudioShell 实现您的目标:
http://studioshell.codeplex .com/
不得不承认到目前为止我还没有使用它,但它看起来很有趣。
Not exactly what you are asking for, but I think you could manage to achieve your goal with StudioShell:
http://studioshell.codeplex.com/
Have to admit that I did not use it so far but it looks very interesting.