Solved

Hide DOS window with VB.NET

Posted on 2002-06-27
7
515 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
Comment Utility
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
Comment Utility
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
Comment Utility
are you coding a malicious code?!
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 22

Expert Comment

by:CJ_S
Comment Utility
Any update?

CJ
0
 
LVL 6

Accepted Solution

by:
anthony_glenwright earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

6 Experts available now in Live!

Get 1:1 Help Now