Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimize or hide this DOS window

Status
Not open for further replies.

kendas

Technical User
Feb 2, 2004
108
SG
hi,
when i run a batch file it always pop up a DOS window on my windows 2000 computer.
how can i Minimize or hide this DOS window?
thanks
 
Hello kendas,

The behavior is controlled by the intWindowStyle argument of the wshshell.run method.
documentation said:
object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
...
intWindowStyle
Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.
...
The following table lists the available settings for intWindowStyle.

intWindowStyle Description
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.
So you can consider it be set to 0 for hiding or 7 for minimized and preserving the active window being active.

regards - tsuji
 
kendas,

This is vbscript forum. We have vb5&6 dedicated forum
Post your question there for adequate followthrough.

If you integerate within a vb application of some sort, you can still create an instance of WshShell and use run method rather than using native shell(). The run method provides the quickest constrol in this aspect of window style.

- tsuji
 
i post here because i can't find a batch file forum.
 
kendas,

You wrote
>use vb to do it

Batch file (.bat/.cmd) is even more distance from vb than vbs from.

- tsuji
 
@echo off
> usermessages.vbs ECHO WScript.Echo^( "Multiple lines?" ^& vbCrLf ^& "OK..." ^)
WSCRIPT.EXE usermessages.vbs
DEL usermessages.vbs

Suppose thats my batch file

so where would i add the line to make the DOS WINDOW hidden ??
I tried adding object.Run(strCommand, [0], [bWaitOnReturn]) right after echo off and that didnt work . im a newbiew with batch files !
 
you must trigger the batchfile using the vbs.
In the vbs you add the wshell.object, and use the wshell.run method to run the batchfile.
you cant use the object.run method directly in a batchfile...

--------------------------------------
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
 
LOL.. as i said. im a newbie with batch files.I dont know a lot of vbs files, so please let me know if there is a way of hiding the window just by addig a line or two in the batch file ???
 
The easy way is to simply make a shortcut to the batch file, in the shortcut, pick run minimised. ;)
 
kendas,

Are you trying to invoke a VBScript from a batch file, or a batch file from a VBScript? The post from tsuji shows what the code would be if you are invoking a batch file from VBScript.

Thanks
 
all what im trying to do is.. hiding the stupid black dos window , when i run my batch file :)

so far , Asspin has the best idea, where u simple have the black window minimized ! but it would be even better if we could just add a few lines to the batch file to make the dos window not appear when we run the batch file.

Any suggestions ?
 
there is a
BASIC:microsoft forum which i have found useful in the past.
however, i think you are sh@T out of luck as i tried doing something similar in the past. i run mine with
ObjShell.Run blla, 0, True\False
which i find perfect.

i would advise porting the code in the batch file into your vb5/6 or vbscript or whatever language you fancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top