Solved

Hide DOS window with VB.NET

Posted on 2002-06-27
7
517 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now