?
Solved

Hide DOS window with VB.NET

Posted on 2002-06-27
7
Medium Priority
?
531 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:Michel Sakr
ID: 7115794
are you coding a malicious code?!
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 22

Expert Comment

by:CJ_S
ID: 7121500
Any update?

CJ
0
 
LVL 6

Accepted Solution

by:
anthony_glenwright earned 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 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