hide DOS window

Discussion in 'Windows XP General' started by dividby0, Sep 28, 2005.

  1. dividby0

    dividby0 Guest

    is it possible to hide a DOS window of batch files (.BAT) after running
    them. i want to run a batch file in windows without showing the window
    on the screen
     
    dividby0, Sep 28, 2005
    #1
    1. Advertisements

  2. dividby0

    R. McCarty Guest

    Modify the properties of the shortcut to run Minimized. If the
    Batch includes an Exit command the window will close itself.
    Or are you asking if you can modify it so that isn't visible in
    any way ?

    "dividby0" <> wrote in message
    news:...
    > is it possible to hide a DOS window of batch files (.BAT) after running
    > them. i want to run a batch file in windows without showing the window
    > on the screen
    >
     
    R. McCarty, Sep 28, 2005
    #2
    1. Advertisements

  3. dividby0 wrote:

    > is it possible to hide a DOS window of batch files (.BAT) after
    > running them. i want to run a batch file in windows without
    > showing the window on the screen

    Hi,

    You can e.g. use a vbscript based batch file launcher for this, this
    way you can hide the batch file completely.

    Run it like this:

    wscript.exe "C:\My Scripts\BatchLauncher.vbs" "C:\My Scripts\tst.bat"

    (BatchLauncher.vbs is the VBScript, tst.bat is your batch file)

    In the code below, it is the 0 in this line that hides the
    batch file execution:

    iRC = oShell.Run("""" & sFilePath & """", 0, True)

    If you want to run it visible, but minimized, change the 0 to 7.


    Content of BatchLauncher.vbs:


    '--------------------8<----------------------
    sTitle = "Batch launcher"

    Set oArgs = WScript.Arguments
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("WScript.Shell")

    If oArgs.Count <> 1 Then
    ' Will die after 10 seconds if no one is pressing the OK button
    oShell.Popup "Error: You need to supply a file path " _
    & "as input parameter!", 10, sTitle, vbCritical + vbSystemModal

    Wscript.Quit 1
    End If

    sFilePath = oArgs(0)

    If Not oFSO.FileExists(sFilePath) Then
    ' Will die after 10 seconds if no one is pressing the OK button
    oShell.Popup "Error: Batch file not found", _
    10, sTitle, vbCritical + vbSystemModal

    Wscript.Quit 1
    End If

    ' add quotes around the path in case of spaces
    iRC = oShell.Run("""" & sFilePath & """", 0, True)

    ' Return with the same errorlevel as the batch file had
    Wscript.Quit iRC

    '--------------------8<----------------------



    WSH 5.6 documentation (local help file) can be downloaded
    from here if you haven't got it already:
    http://msdn.microsoft.com/downloads/list/webdev.asp



    --
    torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
    Administration scripting examples and an ONLINE version of
    the 1328 page Scripting Guide:
    http://www.microsoft.com/technet/scriptcenter/default.mspx
     
    Torgeir Bakken \(MVP\), Sep 28, 2005
    #3
  4. dividby0

    dividby0 Guest

    it worked out just the way i wanted it to
    thanks
     
    dividby0, Sep 29, 2005
    #4
  5. dividby0

    Nishtha

    Joined:
    Feb 15, 2012
    Messages:
    2
    Likes Received:
    0
    I am getting this pop up, on using the script.. can u suggest something

    ---------------------------
    Windows Script Host
    ---------------------------
    Script: C:\BatchLauncher.vbs
    Line: 26
    Char: 1
    Error: Unable to wait for process.
    Code: 80020009
    Source: WshShell.Run

    ---------------------------
    OK
    ---------------------------
     
    Nishtha, Feb 15, 2012
    #5
  6. dividby0

    Nishtha

    Joined:
    Feb 15, 2012
    Messages:
    2
    Likes Received:
    0
    then I changed the
    iRC = oShell.Run("""" & sFilePath & """",0, True)

    to

    iRC = oShell.Run("""" & sFilePath & """",0, False)

    now, there is no pop up message but the window is visible.
    though it was not happening earlier also...
    :(:(:(:(:confused::confused::confused::confused:
     
    Nishtha, Feb 15, 2012
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will

    microsoft dos; ms-dos

    Will, Aug 22, 2003, in forum: Windows XP General
    Replies:
    3
    Views:
    286
    Alex Nichol
    Aug 22, 2003
  2. TheRealMcCoy
    Replies:
    1
    Views:
    294
    Stephanie
    Apr 20, 2004
  3. Tony Frazier

    Running DOS applications in a DOS box

    Tony Frazier, Jun 11, 2004, in forum: Windows XP General
    Replies:
    5
    Views:
    327
    Tony Frazier
    Jun 11, 2004
  4. Standing O

    DOS/Not DOS

    Standing O, Jul 11, 2005, in forum: Windows XP General
    Replies:
    4
    Views:
    181
    Ken Blake
    Jul 11, 2005
  5. Replies:
    2
    Views:
    715
    AllenM
    Feb 27, 2006
Loading...

Share This Page