BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Hide the command window

Thank you for the quick answer on my previous question.

I have a custom action, which is a Visual Basic program which runs after install. When it runs, I see a command window in the background. Is there anyway to hide the command window? The custom action properties are: Source Path <viewer.exe>, Source Type Executable, Command line "[#ClientUpdateProperties.exe]", Synchronous, check return code, deferred, and always execute.

Thanks
Bob
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

In order to do this you need to modify the Visual Basic program so it doesn't use a console.

Also, there is a similar discussion on the forum, please take a look:
http://www.advancedinstaller.com/forums ... en+command

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Hi Cosmin,

I am not using VB script, I’m using Visual Basic. As an experiment, I reduced the program to the following lines

Module Properties_Update
Dim firstTime As Boolean
Sub Main()
firstTime = TRUE
End Sub
End Module

I still see the command window flash. I think it is Advanced Installer which is opening the command window to run the program. Is there a way to hide the command window?

Thanks
Bob
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
I still see the command window flash. I think it is Advanced Installer which is opening the command window to run the program.
Please note that the command window is shown by your program (most likely your program is a console application), not by Advanced Installer. You can check this by running the program without using Advanced Installer.

Like I said in my previous post, the solution is to modify your program (add custom code which hides the window) or recreate it without using a console.

Another approach is suggested in the post I mentioned: you use the sample VBScript to run your program with the command window hidden:

Code: Select all

const WindowStyleStealth  = &H20000000
set WSO = createobject("WScript.Shell")
WSO.run "%comspec% /c MyApp.exe", WindowStyleStealth, false
where "MyApp.exe" is the main EXE of your program.

Let me know if the problem persists after applying one of these methods.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Thanks Cosmin,

I used the sample VBScript to run the VB program. This fixed the problem, the command window is hidden.

I'm still curious why I need to add the extra VBScript layer. I have years of Java experience. I'm new to VBScript and VB. When I made the test program,

Module Properties_Update
Dim firstTime As Boolean
Sub Main()
firstTime = TRUE
End Sub
End Module

I saw the command window in the background. This program does nothing, it does not write to the console, it does not open anything. Is it a console application? Why was there a command window in the background.

Thanks for the terrific forum!!!
Bob
Quadiago
Posts: 71
Joined: Thu May 31, 2007 9:07 am

Hi Bob

I don't know VB either, but I can explain that you should be able to choose what type of application you intend to make when you start your VB project (i.e. console app, windows app, etc.). You have the same situation in .NET and C/C++ as you might be aware.
BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Thanks Quadiago,

I’m new to Installers, VB and VBScript. I’m not using an IDE to create the VB programs, I use VBsEdit and NotePad++.

This is what I have found.

Console Application
To compile
vbc SomeFile.vb
An Advanced Installer custom action will open a command window in the background if the executable is a console application.

Using the above script sample does hide the window and allows you to set the working directory.


Windows Application
To Compile
vbc SomeFile.vb /t:winexe
An Advanced Installer custom action will NOT open a command window in the background if the executable is a windows application

Compile options
/target:exe Create a console application (default). (Short form: /t)
/target:winexe Create a Windows application.
/target:library Create a library assembly.
/target:module Create a module that can be added to an assembly.

This web site discusses the difference between a console application and a Windows application (not much of a difference).
http://www.microsoft.com/mspress/books/ ... /6259.aspx


Bob
Nico-D
Posts: 63
Joined: Mon Aug 18, 2008 2:34 pm

Re:

cosmin wrote:
[...]
Like I said in my previous post, the solution is to modify your program (add custom code which hides the window) or recreate it without using a console.

Another approach is suggested in the post I mentioned: you use the sample VBScript to run your program with the command window hidden:

Code: Select all

const WindowStyleStealth  = &H20000000
set WSO = createobject("WScript.Shell")
WSO.run "%comspec% /c MyApp.exe", WindowStyleStealth, false
where "MyApp.exe" is the main EXE of your program.

Let me know if the problem persists after applying one of these methods.
Hi Cosmin,

I am currently trying this approach to hide evanescent command windows at install. The problem is that I am launching command like "ipconfig" and then parse the output to retrieve the IP address of the host (for instance). I need to get the output, even if the command window is hidden.

Do you have an idea of how to get the output of the command?

Best regards,
-- Nicolas D.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Hide the command window

Hi,
I need to get the output, even if the command window is hidden.
You can try outputting the result to a file:

Code: Select all

ipconfig >> "C:\ip_config.txt"
After the file is created you can use a custom action to parse it. Here you can find some sample VBScript code which may help you.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”