如何从 Windows 的开始菜单搜索中向我的程序传递一个字符串(如 ping)?
当我的程序从开始菜单快捷方式启动时,我想向它发送一个字符串。我看到 ping 会执行此操作,因为我可以输入 ping [和域],它会弹出 cmd 窗口并执行 ping。不过,我认为这一定与我设置的工作方式不同,因为即使程序的快捷方式位于开始菜单中,但当我开始输入任何参数后搜索它时,它就会消失。然后 Windows 将启动一个 Windows 资源管理器窗口,尝试搜索我键入的内容。我必须做什么才能让它像 ping 程序一样注册?
另外,您认为它只是使用 string[] args
来捕获这个吗?
When my program is launched from the start menu shortcut I would like to send it a string. I see that ping does this because I can type in ping [and a domain] and it will pop the cmd window and do the ping. However I think this must be working differently than what I have setup because even though the shortcut to the program is in the start menu, it will disappear when I am searching for it as soon as I start typing any parameters. Then windows will just launch a windows explorer window attempting to search for what I typed. What must I do to get it to register like the ping program?
Also, do you think it is just using the string[] args
to capture this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试从 CMD 运行程序并从那里传递参数?类似于:
<可执行文件的路径>...
是的,提供给程序的任何参数(如上所示)都可以在 main 方法的
args
变量中使用需要。Did you try running your program from CMD and passing the parameters from there? Something like:
<path to your executable> <arg1> <arg2>...<arg N>
And yes, any parameters that are given to the program (as shown above) are then available in the
args
variable that the main method takes.