Advertisement

07.02.2008 at 11:40AM PDT, ID: 23534626
[x]
Attachment Details

How to hide a batch file window called from  VBS

Asked by seriousnick in VB Script

Tags: hide window, batch file, vbs

Hi Experts
I run the below code to ping and email a report on host down.
On the server that this runs this, the command prompt window is viewable while it pings.
How can I hide it (or at least minimise it).
I can work out how to do this in a batch file (with START), but I don't know how to incorporate it into the code below.
Many thanks
NickStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
Set msg = CreateObject("CDO.Message")
Set config = CreateObject("CDO.Configuration")
Set msg.Configuration = config
 
 
'ping the box....
Set oShell = CreateObject("wscript.shell")
Set oExecuteObject = oShell.Exec("ping -l 32 -n 4 -w 500 192.168.2.3")
response = LCase(oExecuteObject.StdOut.ReadAll)
If InStr(response, "reply") > 0 Then
Else
subject = "*** xHost DOWN ALERT"
SendEmail
End If
 
'email subroutine....
Sub SendEmail
With msg
.to = "seriousnick@abc.com"
.from = """Ping Monitor"" <ping@abc.com>"
.subject = subject
End with
 
 
'server info
prefix = "http://schemas.microsoft.com/cdo/configuration/"
 
With config.fields
.item(prefix & "sendusing") = 2
.item(prefix & "smtpserver") = "smtp.smtpserver.com"
.item(prefix & "smtpserverport") = 25
.item(prefix & "smtpauthenticate") = 1
.item(prefix & "sendusername") = "username"
.item(prefix & "sendpassword") = "password"
.update
End With
 
'set up email error logging
on error resume next
 
send_error = error.number
on error goto 0
 
if send_error <> 0 then
wscript.echo "Error Sending Your Message"
wscript.quit 0
else
msg.send
 
end If
 
End Sub
 
Loading Advertisement...
 
[+][-]07.02.2008 at 12:00PM PDT, ID: 21919498

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 12:49PM PDT, ID: 21920000

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.02.2008 at 02:35PM PDT, ID: 21920938

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Tags: hide window, batch file, vbs
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.03.2008 at 02:59AM PDT, ID: 21923921

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 03:01AM PDT, ID: 21923928

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 07:46AM PDT, ID: 21925962

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 06:14PM PDT, ID: 21930440

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906