在 Windows 上隐藏 curl 窗口 [英] Hiding curl Window on Windows

查看:27
本文介绍了在 Windows 上隐藏 curl 窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上一个问题的一个答案提到我可以使用 curl 来获取一个 url;这可以在 Thread.newProcess.spawn 中完成.但似乎无论哪种情况,在 Windows 上,我都会在 curl 连接到网络时出现一个小的命令提示符窗口.

One of the answers on a previous question mentioned that I can use curl to fetch a url; this can be done in Thread.new or in Process.spawn. But it seems that in either case, on Windows, I get a small command-prompt window appearing while curl is going out to the network.

我像这样调用 curl:

I am invoking curl like this:

`curl "#{url}"`

有没有办法隐藏窗口使其不出现?它不仅会夺走游戏的注意力(冻结游戏),而且如果我频繁拨打电话,最终用户也会非常恼火.

Is there any way to hide the window so that it doesn't appear? Not only does it grab the focus away from the game (freezing it), but if I make frequent calls, it will be extremely annoying to the end user.

推荐答案

经过一些试验,我得到了它的工作,双击脚本时没有窗口,我使用 ruby​​ 中的 WMI,您只需要更改 curl 的路径.重要提示:使用扩展名 .rbw 保存它,并确保 ruby​​w.exe 与该扩展名关联.

After some experimenting i got it working, no window when doubleclicking on the script, i use WMI from ruby, you just have to alter the path to curl. IMPORTANT: save it with the extension .rbw and make sure that rubyw.exe is associated with that extenstion.

#hidden_curl.rbw
require 'win32ole'

HIDDEN_WINDOW = 0
cmd = '"C:\\Program Files\\curl\\curl.exe" --output c:\\test2.txt "http://stackoverflow.com/questions/10869789/hiding-curl-window-on-windows"'
objStartup = WIN32OLE.connect("winmgmts:\\\\.\\root\\cimv2:Win32_ProcessStartup")
objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
objProcess = WIN32OLE.connect("winmgmts:root\\cimv2:Win32_Process")
errReturn = objProcess.Create(cmd, nil, objConfig, nil)

希望这适用于您的系统.

Hope this works on your system.

这篇关于在 Windows 上隐藏 curl 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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