How to hide the console of batch scripts without losing std err/out streams

Posted by cooper.thompson on Stack Overflow See other posts from Stack Overflow or by cooper.thompson
Published on 2009-01-29T18:41:59Z Indexed on 2010/05/15 9:04 UTC
Read the original article Hit count: 267

Filed under:
|
|

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

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)?

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).

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?

Edit: 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).

© Stack Overflow or respective owner

Related posts about batch

Related posts about cmd