Link to home
Start Free TrialLog in
Avatar of yazooka
yazooka

asked on

Hide DOS window with VB.NET

We are trying to hide a DOS batch file window using VB.NET.

This is the code that a consultant from long ago (and far, far away) wrote for us, but we're having trouble getting it running - is the syntax different for VB.NET?  (Or are we just ignorant?)  Anyway, here's what we're using:

***
R = WinExec("dosprmpt.pif /c *.BAT", _SW_HIDE)

Do While GetModuleUsage(R) > 0

     DoEvents

Loop
***

Not being a programmer, I need the most specific code possible.  500 points for something that actually works!

Another note:  when the DOS window is hidden, it should NOT BE SEEN ANYWHERE ELSE EITHER (not even the taskbar for a split second).  Is this possible???

We're using NT - if it matters...
Avatar of AzraSound
AzraSound
Flag of United States of America image

Basic code is here:
http://www.mvps.org/vbnet/index.html?http://www.mvps.org/vbnet/faq/main/waitforsingleobject.htm

Just need to alter API declarations in compliance with VB.NET syntax.  In addition, in the RunShell routine that will run your .bat file, you can add these lines denoted by '****:


start.cb = Len(start)
start.dwflags = &H1     '****
start.wShowWindow = 0   '****


Those two lines are needed to provide the "hidden" DOS window effect.
The pif file should set the state of the window. Check the properties of the file and see if you can hide it somewhere...

CJ
Avatar of Michel Sakr
are you coding a malicious code?!
Any update?

CJ
ASKER CERTIFIED SOLUTION
Avatar of anthony_glenwright
anthony_glenwright
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yazooka
yazooka

ASKER

By the way, no, it was not for malicious code.  I work for an organization that doesn't trust its users to blow their own noses.  They don't like for them to see ANY windows, screens, messages, etc. with which they shouldn't interact (press OK, read, etc.).

It's gotten pretty ridiculous actually.  But, hey, appreciate the question anyway, silvers - good for a laugh here!

:)

yazooka
CJ_S,

Ther are points for you regarding this question at https://www.experts-exchange.com/questions/20374776/Points-for-CJ-S-VB-NET.html

SpideyMod
Community Support Moderator @Experts Exchange