隐藏控制台不失STD ERR /输出流 [英] Hiding the console without losing std err/out streams

查看:140
本文介绍了隐藏控制台不失STD ERR /输出流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是类似运行CMD或BAT在静默模式,但有一个额外的限制。

My question is similar to Running a CMD or BAT in silent mode, but with one additional constraint.

如果您使用 WshScript.Run 在VBScript中,您无法访问的过程中/错误/输出流的标准。 WshScript.Exec ,您可以访问标准溪流,但你不能隐藏你的窗口。你怎么能有你的蛋糕(隐藏窗口)和熊掌兼得(有控制台流直接进入)?

If you use WshScript.Run in vbscript, you lose access to the standard in/error/out streams of the process. WshScript.Exec gives you access to the standard streams, but you can't hide your windows. How can you have your cake (hide the windows) and eat it too (have direct access to the console streams)?

目前,我正在想这将创建一个新的Windows站和桌面上一个C ++的可执行文件(见的 MSDN )并运行新的桌面内指定的脚本(我还没有对窗口站和台式机方面的专家,所以这个想法可能被延迟)。

I'm currently thinking about a C++ executable which creates a new Windows Station and Desktop, (see MSDN) and runs a specified script within that new Desktop (I'm not yet an expert on Window Stations and Desktops, so this idea may be retarded).

这想法是松散的基础上神鹰的的 USE_VISIBLE_DESKTOP 功能,这如果禁用,运行神鹰作业将不可见的桌面。我还没有完全想通了,如果这需要提升的priveledge。

This idea is based loosely on Condor's USE_VISIBLE_DESKTOP feature, which, if disabled, runs Condor jobs in a non-visible Desktop. I haven't quite figured out if this requires elevated priveledge.

这种方法的代价是,你的脚本可以消失在地狱,如果用户输入块。

The tradeoff of this approach is that your script can disappear into limbo if it blocks on user input.

有没有人有任何其他想法?或在反馈意见的做法上述?

Does anyone have any additional ideas? Or feedback on the approach outlined above?

编辑:

此外,我们的脚本的目的是设置用户环境,所以运行的其他用户,或者作为一个系统计划的任务是不是一个真正的选择(除非有聪明的办法,我不知道)。

Also, the purpose of our script is to set up the user environment, so running as another user, or as a system scheduled task isn't really an option (unless there are clever tricks I don't know about).

推荐答案

Cygwin的( http://www.cygwin.com / )自带了一个名为run.exe工具,它确实你所要求的一般过程。您可以使用此来包装你的电话为Cscript。 Cygwin的是GNU所以免费商业或个人使用。

Cygwin (http://www.cygwin.com/) comes with a utility named run.exe which does what you are asking for a generic process. You could use this to wrap your call to cscript. Cygwin is GNU so free for commercial or personal use.

这篇关于隐藏控制台不失STD ERR /输出流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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