windows 如何让这个命令在后台运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3900427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make this command run in the background
提问by Serenity
– ping www.google.com –t
I have created a shortcut on desktop and typed this command as it's "Target " ..Now when I double click it, cmd window opens for a sec and vanishes..how do I make it run in the background until this process is manually ended ? The shortcut name's "Ping" and I don't see no Process named "Ping" in the task manager. What I want is to keep on pinging google server
我在桌面上创建了一个快捷方式并输入了这个命令,因为它是“目标”..现在当我双击它时,cmd窗口打开一秒钟然后消失..如何让它在后台运行,直到这个过程被手动结束? 快捷方式名称为“Ping”,我在任务管理器中没有看到名为“Ping”的进程。我想要的是继续 ping 谷歌服务器
回答by Pavan
Solution 1:Do a manual ping from the command prompt and write a -t at the end which makes it a persistent ping. You would have to close the cmd prompt window to stop the ping.
解决方案 1:从命令提示符执行手动 ping 并在末尾写入 -t,使其成为持久 ping。您必须关闭 cmd 提示窗口才能停止 ping。
for example type in command prompt: ping www.google.com -t
例如在命令提示符中输入: ping www.google.com -t
Solution 2:you can create a shortcut like so
解决方案2:您可以像这样创建快捷方式
cmd /c "ping www.google.com –t"
Solution 3:Any free ping utility would do what you require, check on google for "free ping" which will also work.
解决方案 3:任何免费的 ping 实用程序都可以满足您的要求,在 google 上查看“免费 ping”也可以使用。
PK
PK
回答by Barun
set Target as: %windir%\system32\ping.exe www.google.com -t
将目标设置为: %windir%\system32\ping.exe www.google.com -t
and Start in: %windir%
并开始于: %windir%
[EDIT]
[编辑]
TO Hide a cmd window
隐藏 cmd 窗口
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
In main
在主要
IntPtr hWnd = FindWindow(null, "ping");
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0);
}
To Unhide
取消隐藏
ShowWindow(hWnd, 1);