Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running Batch File Invisible

1,093 views
Skip to first unread message

Peter

unread,
Feb 5, 2010, 9:20:04 AM2/5/10
to
Is it possible to set a batch file NOT to appear on the Windows
Taskbar while it's running? (Win 7)

I want the batch file to be invisible to the user while it's running.

Thanks.
Peter

foxidrive

unread,
Feb 5, 2010, 9:34:09 AM2/5/10
to

cmdow is one tool designed with this in mind.

CMDOW [Version x.x.x] Win32 Commandline Window Utility for NT4/2000/XP.
(C) Copyright 2001-2004 Ritchie Lawrence, http://www.commandline.co.uk.

You'll have to test it in W7


--
Regards,
Mic

Peter

unread,
Feb 5, 2010, 2:29:53 PM2/5/10
to
> cmdow is one tool designed with this in mind.
> CMDOW [Version x.x.x] Win32 Commandline Window Utility for NT4/2000/XP.
> (C) Copyright 2001-2004 Ritchie Lawrence,http://www.commandline.co.uk.

> You'll have to test it in W7
> --
> Regards,
> Mic


Mic - thanks for the suggestion. CMDOW looks like it will do the job.

I assume you use it or have used it so I hope you can answer this
question for me. I will be running it from a batch file. According
to the documentation on their web site the command line would be:
CMDOW [Window] /hid

for [Window] I can use either the window's "unique handle in
hexadecimal format" or the window's "caption." The window I want to
hide is the window the batch file is running in. How do I determine
that window's hex format and/or caption?

Thanks.
Peter


foxidrive

unread,
Feb 5, 2010, 4:00:03 PM2/5/10
to
On Fri, 5 Feb 2010 11:29:53 -0800 (PST), Peter <pmok...@gmail.com> wrote:

>> cmdow is one tool designed with this in mind.
>> CMDOW [Version x.x.x] Win32 Commandline Window Utility for NT4/2000/XP.
>> (C) Copyright 2001-2004 Ritchie Lawrence,http://www.commandline.co.uk.
>> You'll have to test it in W7
>
>

>Mic - thanks for the suggestion. CMDOW looks like it will do the job.
>
>I assume you use it or have used it so I hope you can answer this
>question for me. I will be running it from a batch file. According
>to the documentation on their web site the command line would be:
>CMDOW [Window] /hid
>
>for [Window] I can use either the window's "unique handle in
>hexadecimal format" or the window's "caption." The window I want to
>hide is the window the batch file is running in. How do I determine
>that window's hex format and/or caption?

Untested:

@echo off
title HiddenWindow
rest of batch here

and use HiddenWindow as the caption in cmdow


--
Regards,
Mic

ten.n...@virgin.net

unread,
Feb 5, 2010, 5:30:48 PM2/5/10
to
On Fri, 5 Feb 2010 11:29:53 -0800 (PST), Peter wrote:

> The window I want to
> hide is the window the batch file is running in.

::----- START -----
REM Hide this console window so its not shown on taskbar
@CMDOW @ /HID
REM Rest of your script below here
::------ END ------

Message has been deleted

Peter

unread,
Feb 5, 2010, 8:48:37 PM2/5/10
to
> Untested:
>
> @echo off
> title HiddenWindow
> rest of batch here
>
> and use HiddenWindow as the caption in cmdow
>
> --
> Regards,
> Mic

Mic:

I tried that and I get the following error message right after the
line with Cmdow executes in the batch file:
Error: The specified window was not found.

I know the Title command is working because the window title does
change but there is something about the Cmdow command line in the
batch file that's not correct. This is what I have: cmdow ABCwindow /
hid Is that the correct syntax?

Thanks.
Peter

Peter

unread,
Feb 5, 2010, 8:52:41 PM2/5/10
to
> With "TINY C" compile this code:
>
> //hide.c
>
> #include <windows.h>
>
> int main()
> {
>         typedef BOOL (__stdcall *SW)(HWND,int);
>         typedef HWND (__stdcall *FW)(LPCTSTR,LPCTSTR);
>
>         HINSTANCE u32=LoadLibraryA(TEXT("user32.dll"));
>
>         if (u32==NULL) return 1;
>
>         SW sw=(SW)GetProcAddress(u32,"ShowWindow");
>         FW fw=(FW)GetProcAddress(u32,"FindWindowA");
>
>         if (sw==NULL||fw==NULL) return 2;
>
>         sw(fw("ConsoleWindowClass",NULL),0);
>
>         FreeLibrary(u32);
>
>         return 0;
>
> }
>
> And in batch code:
>
> @echo off
> echo.Press a key for hide the current window.
> pause >nul
> hide.exe
> start /wait notepad
> calc.exe

Carlos:

Thanks. That works about 99%. The only thing that happens that I
don't want is when I run the batch file the window opens for a split
second before HIDE kicks in. It goes by very quickly but it is
visible to the user. Is there any way to deal with that issue - so
that the whole process is 100% invisible to the user?

Thanks for your help with this!
Peter

Message has been deleted
Message has been deleted

foxidrive

unread,
Feb 6, 2010, 7:01:39 AM2/6/10
to
On Fri, 5 Feb 2010 17:52:41 -0800 (PST), Peter <pmok...@gmail.com> wrote:

>Carlos:
>
>Thanks. That works about 99%. The only thing that happens that I
>don't want is when I run the batch file the window opens for a split
>second before HIDE kicks in. It goes by very quickly but it is
>visible to the user. Is there any way to deal with that issue - so
>that the whole process is 100% invisible to the user?


Ten's syntax does the job but you are also presented with a flash of the
dos window.

::----- START -----
REM Hide this console window so its not shown on taskbar
@CMDOW @ /HID
REM Rest of your script below here
::------ END ------

Perhaps you can create an executable for your task by using Pure basic etc.

--
Regards,
Mic

Frank P. Westlake

unread,
Feb 6, 2010, 8:50:05 AM2/6/10
to
"Peter"
news:92d01153-a3c6-4796...@k11g2000vbe.googlegroups.com...

> the window opens for a split second before HIDE kicks in.

The thing you want done cannot be done. All console program are run by
CMD and CMD first opens a window before running any console programs. To
prevent the window from opening at all you must begin with a non-console
program. Maybe Visual Basic Scripting is your solution. There was also a
discussion here a year or two ago in which some C code was presented
which will launch the console application through the GUI. Search for
"ShellExecute" and "Frank"; that might locate the discussion.

Frank

Frank P. Westlake

unread,
Feb 6, 2010, 9:24:36 AM2/6/10
to
"Frank P. Westlake" news:hkjs2h$84r$1...@news.albasani.net...

> There was also a discussion here a year or two ago in which
> some C code was presented which will launch the console
> application through the GUI. Search for "ShellExecute" ...

and "Frank"; that might locate the discussion.

This is the discussion I was thinking of but it doesn't do what I
thought:
<http://groups.google.com/group/alt.msdos.batch.nt/browse_thread/thread/70f1fd2b7847f666/e4b5b6bde431b098>The launcher should use WinMain() and launch it through CreateProcess()with a flag for no console. But you will probably be more successful ifyou write your script in Visual Basic Scripting and use WScript.exe tolaunch it.Frank

Peter

unread,
Feb 6, 2010, 9:42:37 AM2/6/10
to
On Feb 6, 7:01 am, foxidrive <got...@woohoo.invalid> wrote:
> ::----- START -----
>   REM Hide this console window so its not shown on taskbar
>   @CMDOW @ /HID
>   REM Rest of your script below here
> ::------ END ------
> --
> Regards,
> Mic

This works. Since I am starting this batch file from a desktop
shortcut I went into the properties for the batch file and selected
Run Minimized. That got rid of the "flash" of the opening DOS window.

Question: The /HID hides the window. I assume it is not necessary for
me to do any type of Un-hide at the end of the batch file since the
window will just close at that point and there will be nothing to un-
hide. True?

Peter

foxidrive

unread,
Feb 6, 2010, 9:46:54 AM2/6/10
to

Check in task manager to see if the process has closed.


--
Regards,
Mic

Todd Vargo

unread,
Feb 6, 2010, 5:54:28 PM2/6/10
to
Peter wrote:


I have used WSH to run batch files in a hidden shell for years. Nothing to
download. No C code to compile. No button displayed on the task bar. Just
plain VBScript code.

'RunHidden.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "YourBatchNameHere.cmd", 0

I keep wscript.exe set as my default host so no additional shortcut is
necessary. However, if you need to run on unknown systems where cscript.exe
might be set as user's default, you can create a shortcut to make sure
wscript.exe will be the host that will run the script. The VBScript code is
easily modified to accept the batch name as an argument to use a single
vbscript to load any batch as hidden.

Caveat #1: Running your batches as hidden means that it must not require any
user intervention to complete. The batch must be fully tested so there are
no user prompts to address before using the RunHidden VBScript.

Caveat #2: If running a second instance of the batch would interfere with
the first instance (ie. overwrite working or temp files), then you should
include a mechanism within the batch code to prevent multiple instances from
running.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

ju.c

unread,
Feb 12, 2010, 12:25:08 AM2/12/10
to
Just use this:

Hidden Start 22 KB (Freeware)
Web: http://www.ntwind.com/software/utilities/hstart.html
Download: http://www.ntwind.com/download/hstart.zip

Example:
HSTART.EXE /NOCONSOLE "C:\Path To\AnyName.bat"


ju.c


"Peter" <pmok...@gmail.com> wrote in message news:47096d4d-2962-4164...@o16g2000vbf.googlegroups.com...

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

0 new messages