# Help with vbscript

**URL:** <https://boards.straightdope.com/t/help-with-vbscript/450485>\
**Category:** Factual Questions\
**Created:** [May 24, 2008, 6:17pm UTC](https://boards.straightdope.com/t/help-with-vbscript/450485 "2008-05-24T18:17:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ice1000](https://avatars.discourse-cdn.com/v4/letter/i/a3d4f5/32.png) [@ice1000](https://boards.straightdope.com/u/ice1000)\
**Post date:** [May 24, 2008, 6:17pm UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/1 "2008-05-24T18:17:16Z")

</div>

I am trying to create a vbscript snippet that can be launched from the command line or by double clicking the file in windows explorer. I need the script to find the current instance of IE and reload the page.

I found that since IE doesn’t write to the ROT table, I can’t use GetObject. I found a workaround but I’m stumped on the refresh page bit.

Here’s what I have so far:

```auto

set shellApp = createobject("shell.application")
for each window in shellApp.Windows
  tname = typename(window.document)
  if tname = "HTMLDocument" Then
	'Reload here

  end if
Next

```

I have tried this to reload the page but it didn’t work:

```auto

ShellApp.Namespace(0).Self.InvokeVerb "Reload" 

```

Does anyone have any idea how to reload the page?

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [May 24, 2008, 9:55pm UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/2 "2008-05-24T21:55:14Z")

</div>

Here’s a variation of a script I put together for Experts-Exchange last week. As written it will refresh all open instances of IE. You can uncomment the commented lines if you want to specify a particular window title or URL.

```auto

'strTargetTitle = "Google"
'strTargetURL = "http://www.google.com"

Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
 
If objShellWindows.Count = 0 Then
	Wscript.Quit
End If
 
For i = 0 to objShellWindows.Count - 1
	Set objIE = objShellWindows.Item(i)
	'strTitle = objIE.Application.Document.Title
	'strURL = objIE.LocationURL

	'If InStr(strTitle, strTargetTitle) Then
		objIE.Refresh
	'End If

	'If InStr(strURL, strTargetURL) Then
		'objIE.Refresh
	'End If
Next

```

---

<div class="post-metadata">

**Author:** ![ice1000](https://avatars.discourse-cdn.com/v4/letter/i/a3d4f5/32.png) [@ice1000](https://boards.straightdope.com/u/ice1000)\
**Post date:** [May 25, 2008, 1:38am UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/3 "2008-05-25T01:38:37Z")

</div>

That is great! I never thought about using the index.

Would you know how to interact with elements on the page? If I have the name or id of a control, how do I click the button, fill in the text box, etc.?

---

<div class="post-metadata">

**Author:** ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)\
**Post date:** [May 25, 2008, 2:51am UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/4 "2008-05-25T02:51:40Z")

</div>

Got me there. I’m not sure that is possible in vbscript without using something like [SendKeys](http://www.devguru.com/Technologies/wsh/QuickRef/wshshell_SendKeys.html).

---

<div class="post-metadata">

**Author:** ![chrisk](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chrisk](https://boards.straightdope.com/u/chrisk)\
**Post date:** [May 25, 2008, 12:11pm UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/5 "2008-05-25T12:11:11Z")

</div>

[QUOTE=ice1000]  
That is great! I never thought about using the index.

Would you know how to interact with elements on the page? If I have the name or id of a control, how do I click the button, fill in the text box, etc.?  
[/QUOTE]

I think that a bright guy in my department was able to figure out some way of doing this - to access the Document object model of an IE window - which then would let you use document.findcontrolByID() or something like that to access the page.

I don’t think he was working in vbs though, so the techniques might not carry over. He could have been using API calls in vb6. I can ask him tomorrow.

---

<div class="post-metadata">

**Author:** ![ice1000](https://avatars.discourse-cdn.com/v4/letter/i/a3d4f5/32.png) [@ice1000](https://boards.straightdope.com/u/ice1000)\
**Post date:** [May 26, 2008, 3:34am UTC](https://boards.straightdope.com/t/help-with-vbscript/450485/6 "2008-05-26T03:34:46Z")

</div>

Yeah, please ask your resident genius. Maybe I can port over whatever language he was working in…
