Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to run a Win32 console executable in hidden mode

210 views
Skip to first unread message

Karen Middleton

unread,
Oct 8, 2004, 9:11:32 AM10/8/04
to
Whenever I run a Win32 console application it invariable starts a CMD
prompt window eventhough this application is not a interactive
application it is a command line application but starts a CMD prompt
window.

Can somebody please give me a VB Script that I can use to run this Win
32 executable to hide the CMD window from appearing.

Thanks
Karen

McKirahan

unread,
Oct 8, 2004, 9:21:22 AM10/8/04
to
"Karen Middleton" <karenm...@yahoo.com> wrote in message
news:a5fd468a.04100...@posting.google.com...

Pseudo code follows...

Option Explicit
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
objWSS.Run "%comspec% /c your_exe your_parms, 1, true
Set objWSS = Nothing

"your_exe" should include the path if the script isn't in the same folder.

"your_parms" are optional.

"/k" instead of /c will keep the window open.


Torgeir Bakken (MVP)

unread,
Oct 8, 2004, 9:28:06 AM10/8/04
to
Karen Middleton wrote:

Hi

0 as the second parameter to the Run method will archive this:


'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

' add quotes around the path because of spaces in it
oShell.Run "cacls.exe ""c:\my test"" /E /G user:F", 0, True


'To redirect the output from cacls to a file (c:\logs\cacls.txt)
' you will need to use %comspec% /c:
oShell.Run "%comspec% /c cacls.exe ""c:\my test"" >c:\logs\cacls.txt", 0, True
'--------------------8<----------------------


The third parameter (True in the example above) will decide if the
script will wait for the command to finish before continuing.


WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:

http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

0 new messages