PC Review


Reply
Thread Tools Rating: Thread Rating: 4 votes, 4.00 average.

hide DOS window

 
 
dividby0
Guest
Posts: n/a
 
      28th Sep 2005
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

 
Reply With Quote
 
 
 
 
R. McCarty
Guest
Posts: n/a
 
      28th Sep 2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      28th Sep 2005
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/scr...r/default.mspx
 
Reply With Quote
 
dividby0
Guest
Posts: n/a
 
      29th Sep 2005
it worked out just the way i wanted it to
thanks

 
Reply With Quote
 
New Member
Join Date: Feb 2012
Posts: 2
 
      15th Feb 2012
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
---------------------------
 
Reply With Quote
 
New Member
Join Date: Feb 2012
Posts: 2
 
      15th Feb 2012
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...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide start menu or hide window icon of window CE. dinhcuong.computer@gmail.com Microsoft Dot NET Compact Framework 2 14th Feb 2007 12:56 PM
F-prot DOS run in Windows DOS BOX or real mode MS-DOS Pat Anti-Virus 2 19th Aug 2005 03:44 PM
Run DOS Commands without DOS Window Popping Up =?Utf-8?B?VmlSdFVhTHBDd0hpWg==?= Microsoft Dot NET 2 21st Jun 2004 05:40 PM
DOS GRAPHICS SCREEN TO SWITCH BETWEEN DOS-WINDOW & FULL-SCREEN DOS =?Utf-8?B?Q0ggQ0hPT05H?= Windows XP Help 0 15th Feb 2004 06:11 AM
Running DOS batch files without DOS window Glenn Wiens Windows XP Basics 2 30th Sep 2003 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 PM.