Miahmichno
asked on
HTA - VBS - Ping until reply
Hello All,
I have created an HTA file that will do several things that I need it to do for me, but the first thing I need it to do is ping our core switch until it receives a reply.
"Why would it not immediately receive a reply?" you may be asking yourself...
We are deploying Cisco's Clean Access Appliance which will remediate the PC's until they are deemed compliant. With that said... back to the script...
SO my HTA will open a html window,
2) kill a couple of process' that need to be killed for the rest to work
3) run Ping against the core switch, and here in lies the issue...
I would like a VBS sub routine that will ping until reply is received
Once received, the rest of the HTA can proceed.
I have included my script, and have also tried to run the routine several ways.
1) within the VBS, it failed.
2) I tried to call the external vbs using objshell.run "cscript //nologo file.vbs",2,true <-- this never acted like it even ran.
3) I tried to call an exteral bat file using the objshell.run "path\file.bat" <-- again acted like it never ran the file.
Preferred method.
within the VBS that is in the body of the HTA, a loop routine that pings until reply, and does not show a dos box. <-- very important. All I want on my screen is the HTA file.
I have created an HTA file that will do several things that I need it to do for me, but the first thing I need it to do is ping our core switch until it receives a reply.
"Why would it not immediately receive a reply?" you may be asking yourself...
We are deploying Cisco's Clean Access Appliance which will remediate the PC's until they are deemed compliant. With that said... back to the script...
SO my HTA will open a html window,
2) kill a couple of process' that need to be killed for the rest to work
3) run Ping against the core switch, and here in lies the issue...
I would like a VBS sub routine that will ping until reply is received
Once received, the rest of the HTA can proceed.
I have included my script, and have also tried to run the routine several ways.
1) within the VBS, it failed.
2) I tried to call the external vbs using objshell.run "cscript //nologo file.vbs",2,true <-- this never acted like it even ran.
3) I tried to call an exteral bat file using the objshell.run "path\file.bat" <-- again acted like it never ran the file.
Preferred method.
within the VBS that is in the body of the HTA, a loop routine that pings until reply, and does not show a dos box. <-- very important. All I want on my screen is the HTA file.
<HTML>
<HEAD>
<TITLE>Running CFCU Apps</TITLE>
<HTA:APPLICATION ID ="oHTA"
APPLICATIONNAME = "RunRoutine"
BORDER = "Thin"
BORDERSTYLE = "Normal"
CAPTION = "Yes"
ICON = ""
INNERBORDER = "No"
MAXIMIZEBUTTON = "Yes"
MINIMIZEBUTTON = "Yes"
NAVIGABLE = "Yes"
SCROLL = "Yes"
SCROLLFLAT = "No"
SELECTION = "Yes"
SHOWINTASKBAR = "No"
SINGLEINSTANCE = "No"
SYSMENU = "Yes"
WINDOWSTATE = "normal"
>
</HEAD>
<script language="VBscript">
Sub Window_onLoad
intWidth = 500
intHeight = 400
Me.ResizeTo intWidth, intHeight
Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
Call ProcessKill
Call Ping
'Call Websense
Call iAtlas
Call LoginScript
Call CloseWindow
End Sub
Sub Ping
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.run "%logonserver%\Netlogon\PingCheck.bat",2,True
'objShell.run "ping 10.10.10.19",2,true
End Sub
Sub Websense
' Used to create the Websense folder.
Dim fso, fldr, destination, source, webA, webB, webC, objShell
set fso = Createobject("Scripting.FileSystemObject")
source = "%logonserver%\websense\*.*"
destination = "C:\Websense\"
If Not fso.FolderExists(destination) then
set fldr = fso.CreateFolder("c:\websense")
End If
fso.copyfile source,destination
Set objShell = CreateObject("wscript.shell")
webA="C:\Websense\LogonApp.exe "
webB="http://<IPADDRESS>:<port#> "
webC="/NOPERSIST"
ObjShell.Run WebA & WebB & WebC,1,1
End Sub
Sub ProcessKill
'Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'iAtlas.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
End Sub
Sub iAtlas
'Option Explicit
Dim objWMIService, objProcess, objCalc
Dim strShell, objProgram, strComputer, strExe
strComputer = "."
strExe = "C:\Program Files\iMM\iAtlas\iAtlas.exe"
set objWMIService = getobject("winmgmts://" & strComputer & "/root/cimv2")
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
End Sub
Sub LoginScript
Dim objShell
Set objShell = CreateObject("wscript.shell")
ObjShell.Run ("%logonserver%\NETLOGON\Coastal2.bat"), 2, True '<-----Displays the window as a minimized window.
End Sub
Sub CloseWindow
self.close
End Sub
</script>
</HEAD>
<body STYLE="font:8 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
<table width='90%' height = '100%' align='center' border='0'>
<tr>
<td align="center">
<h4>Starting CFCU Login Process</h5><br>
<h5>Please be patient</5><br><br><br>
<h2><Font color = FFD700><b><br><br>Do not close this window</b></font></h2>
</td>
</tr>
<tr>
<td align='center'>
<br><br>
<span name="span_text" id="span_text"></span>
<br><br>
</td>
</tr>
</table>
</body>
</HTML>
ASKER
Thanks for the help...
I am now receiving error on line 31 Type mismatch: 'Ping'
I am now receiving error on line 31 Type mismatch: 'Ping'
Line 31:Set objShell = CreateObject("WScript.Shell")
Line 32:boolPinged = Ping("10.10.10.1")
ASKER
IP is suppose to be 10.10.10.1 instead of 10.10.10.19
sorry for the confusion. Still no workie.
sorry for the confusion. Still no workie.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Sorry for the delay. It works great. Thank you
No problem. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
Regards,
Rob.
Open in new window