[Batch] Hide cmd batch window

Discussion in 'Scripting' started by Cool8818, Nov 30, 2010.

  1. Cool8818

    Cool8818 MDL Novice

    Jan 18, 2010
    18
    1
    0
    hi guys How can hide Command window when batch file runs

    this is my xp.bat file thank you

    "C:\wxxx\xp.bat"
     
  2. searchengine

    searchengine Guest

    #2 searchengine, Jan 28, 2011
    Last edited by a moderator: Apr 20, 2017
    use a .vbs file to run your batch file ...

    example ....

    HideBat.vbs

    Code:
    CreateObject("Wscript.Shell").Run "NAME_ME.bat",0,True
    "NAME_ME" change to name of your .bat file, that you wish to run hidden.
     
  3. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,519
    7,103
    120
    Very nice script, thanks.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. wulai

    wulai MDL Novice

    Mar 24, 2011
    5
    0
    0
    very nice script, thanks very much.
    i never though the command window can run in a hide state
     
  5. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    710
    116
    30
    it is possible to hide the cmd window when a bat runs by using the program "hstart" --which is what I use for doing this

    example:

    @ echo off
    Start hstart.exe /NOCONSOLE "name.bat"

    there are also various other commands that can be used with "hstart" as well
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #6 Compo, May 1, 2011
    Last edited by a moderator: Apr 20, 2017
    There are some problems with this example. First of all if you are hiding the batch file, what would be the point in turning the echoing off, (you are not going to see it echo anyhow). Next is that when using the start command the first quoted string to follow it is often seen a the TITLE, that means there may be no batch file actually passed to hstart.
    Code:
    @START "" Hstart /NOWINDOW "My Batch.cmd" 
    There should be no reason why you couldn't just run it like this either:
    Code:
    @Hstart /NOWINDOW "My Batch.cmd"
    The commands above assume version 1.1 of the application change to /NOCONSOLE for the earlier version.
     
  7. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    710
    116
    30
    the version i have uses /NOCONSOLE, and not /NOWINDOW,

    and you are probably right about the echo off, it's just habit i guess, but the other

    Start hstart.exe /NOCONSOLE "name.bat"

    is the proper syntax cause it will run the batch in question every time as long as the batch is in the same directory as hstart.exe, so go argue with someone else.

    i was just trying to help so don't be a dick :mad:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #8 Compo, May 1, 2011
    Last edited: May 2, 2011
    First things first, I definitely stated that /NOWINDOW was the correct parameter for version 1.1 and that /NOCONSOLE was correct for earlier version. All I have done is inform all readers that there are different versions and that their parameters have changed with those versions.

    On the second point, I'm going to give you the opportunity to practice and find out for yourself, (just in case there has been a delay in your reading and comprehension skills prior to writing). I am however 100% certain that using a quoted string without a TITLE whilst issuing the START command is problematic. A problem which is solved by providing a title, even an empty one as per my advice.

    In my book I had not argued, I posted information with intent only to help. It is you who has taken a contrary position.

    I'd sooner be a dick and correct that someone incapable of admitting lack of knowledge or a mistake.
     
  9. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    710
    116
    30
    and i'm telling you, that you are wrong, so face it,

    Start hstart.exe /NOCONSOLE "name.bat"

    works every time. try it for yourself before you argue with me some more, and you aren't trying to help, all you are trying to do is make yourself sound intelligent on a subject you are oblivious to here in the virtual world, and i got news for you, your rep here don't mean jack in the real world...

    i don't really care what you think you know, but don't tell me i'm wrong when you have no idea what you are talking about :mad:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    Now read the above, which I've also highlighted in my previous posts just to be sure, and
    explain where I have told you that your command doesn't work.

    All I have done, let me say it again loud and clear, is issuing the START command and using a quoted string without a TITLE is often problematic. Best practice is therefore to use a TITLE, blank or otherwise.