Run console app in hidden window

VBNET_LOONEY

Member
Joined
Nov 24, 2004
Messages
11
Programming Experience
3-5
Hello,

Is it possible to run a console window hidden? The console will be run directly and not launched by another application.
The console app does not need to display any data just do its job but whenever it runs the black console window appears.

TIA :)

Looney.
 
i'm sure there is a way to do it, i'll have ta search for an article

but if this is a consol app that you're writing (or have access to the source code) you could just copy the functionality of the consol app into the current app you're working on so that it'd built in and doesnt require the use of an another appication when it comes to deployment
 
Hello,

Well the plan is to have several little console apps doing various things and all being scheduled by the Windows Task Scheduler. The problem is that when the task scheduler executes an app a blank console windows appears for the duration of the execution, which is what I want to avoid.

Thanks,
Looney.
 
Try this ...

Module
Module1
' Programmmer BinaryGuy

Public Declare Function GetConsoleTitle Lib "kernel32" Alias "GetConsoleTitleA" (ByVal lpConsoleTitle As String, ByVal nSize As Integer) As Integer

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

Public Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer

Const SW_HIDE = 0

Const SW_SHOWNORMAL = 1

Const SW_NORMAL = 1

Const SW_SHOWMINIMIZED = 2

Sub Main()

'<VBFixedString(150)>

Dim strTitle As String

strTitle = Space(256)

Dim rtnLen As Long

rtnLen = GetConsoleTitle(strTitle, 256)

If rtnLen > 0 Then

strTitle = Left$(strTitle, rtnLen)

End If

'MsgBox(strTitle)

Dim hwnd As Int32

hwnd = FindWindow(vbNullString, strTitle)

' hide the app

ShowWindow(hwnd, SW_HIDE)



MsgBox(hwnd)

End Sub

End
Module

 
Back
Top