Solved

Hide DOS window with VB.NET

Posted on 2002-06-27
7
519 Views
Last Modified: 2008-02-01
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...
0
Comment
Question by:yazooka
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 7114759
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.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7114815
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
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 7115794
are you coding a malicious code?!
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 22

Expert Comment

by:CJ_S
ID: 7121500
Any update?

CJ
0
 
LVL 6

Accepted Solution

by:
anthony_glenwright earned 500 total points
ID: 7128522
You don't need to use API calls, etc - You can do what you want within the .NET framework using the Process class:

Dim myProcess As Process
Dim strReport as string
         
myProcess = New Process()

myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.FileName = "dosprmpt.pif"
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.Arguments = _
  Chr(34) & "/c *.BAT" & Chr(34)

myProcess.StartInfo.UseShellExecute = False

myProcess.Start()

strReport = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()
myProcess.Close()

' Output is in strReport
0
 

Author Comment

by:yazooka
ID: 7337657
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
0
 

Expert Comment

by:SpideyMod
ID: 8067397
CJ_S,

Ther are points for you regarding this question at http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20374776.html

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question