Solved

Hide DOS window with VB.NET

Posted on 2002-06-27
7
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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