troubleshooting Question

HTA - VBS - Ping until reply

Avatar of Miahmichno
Miahmichno asked on
VB Script
6 Comments1 Solution2458 ViewsLast Modified:
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.
<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 CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros