View Full Version : Possible to hide a dos window custom extension?

02-06-2004, 07:12 PM
I am running a dos batch file as a custom extension, can the window be hidden? There are 3 or 4 of them so they flash by and some users will think things are going crazy.


02-10-2004, 01:18 AM
I assume you are using a .vbs custom action using a WScript shell object to execute your batch file?

I so you can use the following:
Set VWScript = CreateObject("Wscript.Shell")

VWScript.Run "yourfile.bat",0, true

where 0 = don't show the window and true = wait for this to finish executing before moving onto the next step in the.vbs file.

Hope this helps

02-10-2004, 01:10 PM
In looking for solutions, I noticed the batch file was just calling an .exe, so I do that instead.

Thanks for your reply, it may be useful to me someday.


02-12-2004, 11:37 AM
hey jturner maybe you can give a little help with my issue - http://community.installshield.com/showthread.php?s=&threadid=129205

What I had to do was create a bat file that will do this but obviously I get the pop up dos window. I am not running a custom VBS file to execute it however. I just set the bat file and the downloader in the language section with a custom action to execute the bat file after a custom set up choice is made. It works fine, except I would like the dos window to not show up. However is chaning this to execute via a custom script will work better *and* hide the dos window - Do you have a full example of a vb script that runs the bat when a selection is made *and* hides the dos window as the bat file is executing?

02-12-2004, 08:22 PM
I had a look at your original thread and I don't think I can offer you any help there... I have done nothing like that before..

I haven't actually called a .bat file from my .VBS before, I primarily use the Wscript.Shell object to call osql to make changes to an MSDE database.

When I set the window property to 0, the dos shell is not displayed to the user. I am just assuming that the same will occur when calling a .bat file.

The code I have provided is all you need to actually execute a program via .VBS, just change 'yourfile.bat' to the name you require.

I usually set the window to display the first time I create a new custom action just so I can confirm it is being run correctly, once I am happy I set the property to '0' again.

For more info on the Run method visit

or for VBScript in general


02-13-2004, 12:42 PM
Well thanks, none of that works. I tried your example but all that happens is the pop up saying "a script can not be run". I went through the MS site and tried many of the examples but none would work - with the exception of the "Verify Method".

So I am wondering if this is an issue with isx5. On the other hand the VS script needs to know where the bat file is - in my case it is going to the [SUPPORTDIR], but if I put in [SUPPORTDIR] the same error message pops up, so it doesn't seem to matter one way or the other.

I was suprised that even the simple:

Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing

Returned an error. Is there somehting simple I am overlooking here?

Out of all I tried, as I said above, this is the only sample the would work:

Dim Signer, UnsignedText, Trusted
Set Signer = CreateObject("Scripting.Signer")
UnsignedText = _
"Dim X " & vbCrLf & _
"X = 123" & vbCrLf & _
"WScript.Echo X" & vbCrLf
Trusted = Signer.Verify(".VBS", UnsignedText, True)

02-15-2004, 07:54 PM
Well, I don't know what to say...
It works for me as is.
I have no extensive knowledge of VB Script... All I know is from the two articles I referenced, so unfortunately I can't really help you troubleshoot it...

The only thing I can think of is it sounds like you don't have the Windows Scripting(?) environment available to use...

Have you selected the VBScriptRuntime Merge Module for inclusion in your package? If not, you should try adding it. If you have already selected it, then I am all out of ideas.

Good luck, hope you get it sorted. Post back when you do with the solution to help others in the future.


02-15-2004, 11:43 PM
If you mean .NET - I have it and use it, I edit video with Vegas and it uses (needs) .NET in order to run scripts. If you mean someting else let me know.

as I say - just more or less cutting ansd pasting the examples at the MSDN site don't seem to do anyting but retuirn an error. There could be several reasons for this.

Let me ask you this - in your method, where is your bat file in relation to the install package? As I mentioned I put mine into the language folder which goes to the users system into the [SUPPORTDIR].

So here is your script -

Set VWScript = CreateObject("Wscript.Shell")

VWScript.Run "yourfile.bat",0, true

So how exactly do you use the "VWScript.Run "yourfile.bat"" portion? Do you put 'VWScript.Run [SUPPORTDIR]name.bat'? Or do you put 'VWScript.Run C:\whateverdirectory bat file is in\name.bat'? Or what do you put?

02-16-2004, 12:14 AM
No I don't mean .NET.

Check under the Redistributables icon and ensure that the
VBScriptRuntime is selected.

Like I said I don't use it with a .bat file. I use it to call osql which is in the path or i reference directly with
VWScript.Run "C:\SQL Server\osql -U sa -P password etc..",0,true

Also try running your setup.exe with the following parameters:
Setup.exe /v"/lv C:\instlog.txt"

This turns on logging of the install and might help provide some more info.

Otherwise, it might be that your bat file is not being deployed to the supportdir like you think it is... the logging should confirm or deny this...

02-16-2004, 10:45 AM
Thanks so much for the effort here.

Going back to the start so to speak. CUrrently I I have it working fine. The downloader and the bat file are going to the [SUPPORTDIR] just fine. if you run the installer as is when the user picks the option it will donwload the file and install it. It works perfect. *However* this thread caught my eye because of the hiding of the dos window.

When you said Windows scripting I thought you meant .NET. The VBS Runtime you mention would only affect the end user and I believe it only affects those running Windows NT and 95. I know in the past when i have put together an installer for XP only sysytems I get the 'error' that I have no included the VBS runtime but I recall it saying that it is only needed for NT or 95 installs. Either way I will double check and see if it makes a differance.

I will also hard code the [SUPPORTDIR] path and see if it makes a differance as well.

Film at 11. :)

02-16-2004, 08:09 PM
No problems..

All I know is that I have included the VBScriptRuntime module and it all works for me. I can't find anywhere where it states that the VBScriptRuntime is only required for NT etc..

I would recommend running setup with logging enabled like I suggested... that should let you know hopefully whats not working.

02-17-2004, 07:11 PM
No luck. I hard coded the path and watched the directory as the installer was being loaded and the files were there, i the correct place. (Sorry - the bat file and dowloader were in the correct place is what I am saying)

I am wondering now if this doesn't work with a bat file. ?? You mentioned that you don't use it with a bat file so at this point we are going on "could work/might work/should work".

And I did click on the runtime but it didn't make any difference.

02-17-2004, 08:14 PM
That is surprising.

If I get a chance today I will try with a .bat file for you and let you know how I go.

02-20-2004, 12:48 PM
//This is the prototype and definitions for the "_LaunchAppEx" Function -- leave these alone.
#define STILL_ACTIVE 0x00000103

#if _ISCRIPT_VER < 0x600
#ifndef BYVAL
#define BYVAL

prototype BOOL kernel32.CreateProcessA(POINTER, BYVAL STRING, POINTER,
prototype BOOL kernel32.GetExitCodeProcess(NUMBER, POINTER);
prototype NUMBER kernel32.WaitForSingleObject(NUMBER, NUMBER);
prototype BOOL kernel32.CloseHandle(HWND);

// End of "_LaunchAppEx" Definitions

// Function Name: _LaunchAppEx
// Description: Extended version of LaunchAppAndWait
// Parameters: This function takes the same parameters as the built in
// LaunchAppAndWait function, plus:
// nShow: Use SW_SHOWNORMAL for normal window, SW_HIDE to launch the
// program invisible, or any other SW_* constant
// nTimeOut: Time-out interval, in milliseconds. The function returns
// if the interval elapses, even if the launched process is
// not finished (only if WAIT was specified in the third
// parameter). Use -1 to wait indefinitely.
// nvExitCode: Returns the result code of the launched program (only if
// WAIT was specified in the third parameter). If the function
// returns before the launched process is finished (because the
// time-out interval has elapsed) STILL_ACTIVE is returned in
// this parameter.
// Return values: -1 if the program can't be launched, 0 in all other cases.
function _LaunchAppEx(szProgram, szCmdLine, nWait, nShow, nTimeOut, nvExitCode)


siData.cb = 68;
siData.lpReserved = NULL;
siData.lpDesktop = NULL;
siData.lpTitle = NULL;
siData.dwX = 0;
siData.dwY = 0;
siData.dwXSize = 0;
siData.dwYSize = 0;
siData.dwXCountChars = 0;
siData.dwYCountChars = 0;
siData.dwFillAttribute = 0;
siData.dwFlags = 1; //STARTF_USESHOWWINDOW
siData.wShowWindow = nShow;
siData.lpReserved2 = NULL;
siData.hStdInput = NULL;
siData.hStdOutput = NULL;
siData.hStdError = NULL;

if (kernel32.CreateProcessA(NULL, szProgram + " " + szCmdLine, NULL, NULL,
TRUE, 0, NULL, NULL, &siData, &piData) = 0) then
return (-1);

if ( nWait != WAIT ) then
nvExitCode = 0;
return 0;

kernel32.WaitForSingleObject(piData.hProcess, nTimeOut);

kernel32.GetExitCodeProcess(piData.hProcess, &nvExitCode);


return 0;