Solved Why do I keep getting Permission denied in VBS?

August 8, 2017 at 03:23:13
Specs: Windows 10, AMD A10-6700 APU 3.70 GHz / 8 gb RAM
I have a VBS script in an HTA in which I use document.location to detect the current web adress of an IE window, but each time I run the code it outputs: "Permission denied".

The code below is supposed to open "" in IE, and (when finished loading) open a MsgBox if the web adress (IE.document.location) actually is "".

Note: My original code is much longer than this, I just made this example code to show you what my problem is.

<script type="text/vbscript">
Sub Wait(Time)
  Dim wmiQuery, objWMIService, objPing, objStatus
  wmiQuery = "Select * From Win32_PingStatus Where Address = '' AND Timeout = " & Time
  Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
  Set objPing = objWMIService.ExecQuery(wmiQuery)
  For Each objStatus in objPing
End Sub

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate ""

Do Until IE.ReadyState = 4

Set url = IE.document.location
If url = "" Then
  X = MsgBox("You're on Youtube")
  X = MsgBox("You're not on Youtube")
End If

See More: Why do I keep getting Permission denied in VBS?

Report •

August 8, 2017 at 09:19:38
✔ Best Answer
Set url = IE.document.location
Should be:
url = IE.LocationURL

How To Ask Questions The Smart Way

Report •

August 8, 2017 at 10:13:07
I LOVE YOU MAN!!! You don't know how frikin' much I've been searching for solutions to this problem, I've posted this question on all programming forums I could found. Thanks a lot!

Report •
Related Solutions

Ask Question