Question

window.navigate command getting "Access Denied" error

Asked by: domj

For some reason I cant get the window to navigate to the new address. The address is a local path to a file in the temp directory. Code is below. The function main simply uses a recordset to create a new html page in the users TEMP directory and the window.navigate is meant to just open this page but no go! I'm sure it is something simple but, any ideas?

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<script language=vbscript>
'**Start Encode**
Set fso=CreateObject("Scripting.FileSystemObject")
Set dbCon = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
pUBLIC STRdbcON
Public fsofile
Set wshell=CreateObject("WScript.Shell")
Public PCName
Public Curdir

pcname=Wshell.ExpandEnvironmentStrings("%USERNAME%")
curDir=WShell.ExpandEnvironmentStrings("%Temp%")

Function sesbyDate()
strDBCon="Provider=SQLOLEDB.1;User ID=dbUser;Initial Catalog=Templates_Synch;Data Source=foneent"
dbCon.Errors.Clear
dbCon.Open strDBCon

Main()
window.navigate CurDir & "\" & pcname & "Report.html"

End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dom

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-10-06 at 18:21:22ID21158894
Tags

denied

,

access

Topic

Web Languages/Standards

Participating Experts
6
Points
500
Comments
28

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. 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.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Wscript.shell work in the server!!!
    I have a problem, i made this Script: <script language="VBScript"> sub dos_onclick Dim wscr set wscr=CreateObject("WScript.Shell")wscr.run "\\ags_system\si$\cheques\sisch.exe" Set wscr=Nothing Ejecutar =2 end sub </script>&...
  2. Permission Denied: 'CreateObject'!
    Hello, I have an ASP site that generates Excel reports. In fact I am using the "Excel.Application". I can generate the reports without any problems on my development machine. But one of the test servers failed to do that, I am getting the following error: Error Typ...
  3. Permission Denied error using WScript.Shell in VBScript
    I have the same script running on 3 Windows 2000 Servers and I'm getting a Permission Denied error on 1. Here's the code (below) the problem is with WScript.Shell. I've checked and permissions in IIS and for the IUSR account are the same on all servers. Permission for \WIN...
  4. VBScript - Not getting any output  (Wscript.shell  and W…
    I am not getting any output to the screen with the following script. I am not sure what I have done wrong. I am use to doing things server side instead of client side. Thanx, Soren <html> <head> </head> <body> <script type="...
  5. Using wscript.shell to launch an app from VBScript
    hi guys, Ive added a script behind a button on an Outlook form that launches an app if the Save & Close button is clicked. The problem is, the Run command fails on the wscript.shell object. It seems to be an issue with using a spae in the run string. ie. if I put "C...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ZylochPosted on 2004-10-06 at 18:25:01ID: 12244799

Hi domj,

window.navigate is IE only (not really matter since you're using VBScript. I wonder. Does window.location.href=CurDir & "\" & pcname & "Report.html" work?

Regards,
Zyloch

 

by: domjPosted on 2004-10-06 at 18:28:42ID: 12244811

nope, same message "permission denied"

Dom

 

by: ZylochPosted on 2004-10-06 at 18:32:11ID: 12244821

So you're using something like:

file://c:/WINDOWS/Temp/

 

by: domjPosted on 2004-10-06 at 18:35:22ID: 12244840

The file is being created in the users temp folder. Earlier in the script the curDir=WShell.ExpandEnvironmentStrings("%Temp%") line gets the current users temp fodler using the %TEMP% variable. Then I create a new text file in this directory and write html to it, dependent on the results of the recordset that is opened in the main() function. The file is created properly and i can manually navigate to it but I want the browser to jump to it, once it is finished creating it so that it is seamless for the end user.

Dom

 

by: ZylochPosted on 2004-10-06 at 18:40:43ID: 12244869

Try this:

window.navigate "file://" & CurDir & "\" & pcname & "Report.html"

 

by: domjPosted on 2004-10-06 at 18:45:40ID: 12244898

nope, same again. For some reason its not letting me change the access in code. weird. its got to have to do with security because when i run it locally (ie, when the page is not published) it runs fine but once it is run from a web server it fails.

Dom

 

by: ZylochPosted on 2004-10-06 at 18:48:47ID: 12244913

Oh, you're running it from a webserver. Yes, it is the security. I don't believe you can get past that... Otherwise, a person could just change files on your computer without you knowing

 

by: domjPosted on 2004-10-06 at 18:56:44ID: 12244945

yeh but it is doing the file stuff fine. the file is creating and everything without any problems. to facilitate this the end user needs to add the intranet site to trusted sites and heavily reduce the activex security for these sites but it works fine once these changes have been done. The stuff that should be really secure (ie. actually changing files and reading environment variables) is working fine once the appropriate changes have been made. The bit that doesnt work is simply navigating to view a html file on the local machine. all it is is trying to change the address of the current window which I thought would be the easiest thing in the world to do. its just the equivalent of clicking on a link but it doesnt work. (you can tell how little web development i have done!)

dom

 

by: ZylochPosted on 2004-10-06 at 19:19:12ID: 12245055

Creating the file is totally different from accessing it. I'm not immensely familiar with ASP/VBScript. Possibly there's a way, but it's beyond my knowledge.

 

by: domjPosted on 2004-10-06 at 19:21:56ID: 12245066

Thanks anyway Zyloch. appreciate your help. anybody else? Have increased points value to 500.

Dom

 

by: sgayatriPosted on 2004-10-06 at 23:17:29ID: 12245937

Just try something like this -- using javascript
<input type=button value=click Onclick=window.open("../../yourfile")>

 

by: domjPosted on 2004-10-06 at 23:23:58ID: 12245948

sgayatri, thanks for the input but if i was going to do that i may as well just post a link. i can find ways around it but i am just intrigued as to why i am having this problem. for example, i can use the wshell.run command to shell the path of the file and open in a new browser. therefore i could shell any command including hostile script. i can't understand why it would block me then from doing something as simple as navigating the current window to a new page.

dom

 

by: thunder_moosePosted on 2004-10-07 at 00:22:03ID: 12246246

Hey there,

This might sound silly, but do you close the file? It could be that the file is still open for writing or for append and then you try and navigate to it while it's still in use.

Cheers,
TM

 

by: Adesso21Posted on 2004-10-07 at 01:37:30ID: 12246676

IE had some issues with cross domain security and they solved it by NOT ALLOWING it at all. This means that if you want to use a frame to load a diffrent domain from the current one it just tells you Access Denied..

The window.open option could solve your problem but if not .. try using a shell script to execute a new instance of IE with the file location of the current users file. Also remember that the shell command has to have local admin rights to do this or you would be back to the same problem...

Here is a alternet solution..

Instead of writing the file to the users PC.. let them download the thing... this way they can access it at there own will... To get that right send the browser a mall-formed header so it doesn't display the HTML file but wants to download it.. the rest is then up to the user..

Another idea is to write the file to a common file server and then redirect the user to that file server.

Cross doamin access is a bit of a mission...

Good Luck
Adesso21

 

by: sgayatriPosted on 2004-10-07 at 02:10:29ID: 12246828

domj,
I am not very sure about why you get that error. May be due to the reasons explained by Adesso21.
I could not understand much of what he is trying to tell.
I happened to see ur question in VB section and out of curiosity came here and posted my opinion.
That's all.
Adesso21,
If it is 'cross domain issue' , then enabling the security option 'Access data sources across domains'
in internet options , should solve the problem... Am I right?

 

by: domjPosted on 2004-10-07 at 02:32:53ID: 12246908

Hi all,

Here I was thinking that it would be an easy fix! thunder_moose, yes the file is closed before I try to access it but I have been caught out with this before (as I am suremost people have)!

Adesso21, firstly, the page is published and accessed all on a common domain to which I am a Domain Admin and therefore I can't see where there should be a permissions problem. The window.open command doesnt work for me either (same issue, "Access Denied"). The shell command does work fine and I could use this method but then the user can't use the back button to get back to the first page and also it leaves the old page up and if I use a window.close to try and ditch it it comes up with the "Are you sure you want to close it" prompt. I am not sure what the suggestion regarding the downloading thing is. The reason that I am using a temp folder on the local PC is that the page is to display a report for a FTP synchronisation tool that I have written. The logs get pulled up into a SQL 2000 db and then I wanted a nice easily distributable reporting option to allow our help desk to access custom reports. The page allows the user to click on a number of links to run reports that it then prompts for user input and uses this info and embedded vb code to query the SQL db. It creates a recordset and then goes through each record, writing HTML containing this information into a new text document and then displays this document (or is meant to at least). The reason that this is done client side is because I dont have the skills to look at ASP or any server side solution.

All that said, the entire thing works great and apart from some early problems with security and the activex objects (like the fso and the environment variable access) and this one hiccup, the file gets created fine and you can manually go to the page and it displays like a charm. Its just that for some reason, IE locks down all access from code to anything that will get the current page to navigate away. I could redirect to a common file server but I dont know if that would even work. It might be worth a try and if someone was able to say "oh yeah, you cant do that because..." then i could look at another option but it just seems like the most trivial thing to be able to do from a webpage.

Thanks all for you input... Am still interested to hear if anyone has any further insight or common experience with a similar issue.

Dom

 

by: Adesso21Posted on 2004-10-09 at 03:25:53ID: 12265665

sgayatri

I am not sure that changing the setting in IE will do anything.. Last I read somthing about Microsoft wanting you to create some kind of Trusted certificate between the two domains and then implementing some funny browser security check .. I gave up..

As for the real question DomJ.. You are going to have to get your hand dirty with some kind of server side scripting.. The way you are going now is almost not possible. I get what you are trying to do, and let me tell you.. it's a breeze in server side scripting..

I like using PHP but ASP should be fine.. this is not rocket sience ... reporting.. but the way that you are trying to do it.. could be..

I hope you get a solution..

Regards

Adesso21

 

by: JuergenHartlPosted on 2004-10-09 at 17:45:35ID: 12268629

A suggestion: Why don't you create the file on the server and then link to that file vis HTTP ?
The main page would hve to be a ASP ot CGI page

 

by: ZvikaPosted on 2004-10-11 at 05:15:29ID: 12275508

Excuse me, but shouldn't it be:
window.navigate CurDir & "/" & pcname & "/" & "Report.html"
or
window.navigate CurDir & "\" & pcname & "\" & "Report.html"

rather than:
window.navigate CurDir & "\" & pcname & "Report.html"

What I would suggest you to do first is print out (either in MsgBox, or better just to dynamically write it somewhere in the doc) the value of [CurDir & "\" & pcname & "Report.html"] and then just copy it and paste it to the address field in the browser.
also, put this output here, maybe we can see something in it....

Good luck
Zvika

 

by: ZvikaPosted on 2004-10-11 at 05:31:11ID: 12275610

I'm quite sure that all you're missing is the extra "\" between pcname & "Report.html"...

Lemme know if that it...

 

by: domjPosted on 2004-10-11 at 13:56:19ID: 12280936

No, that syntax is correct. The file path is "C:\Documents and settings\DominicJ\Local Settings\Temp\DominicJReport.html". I could copy and paste the value. Seems like a very poor way of coding it and open to problems. What if the user copies something in the meanwhile? How do I give focus to the address bar?

Dom

 

by: ZvikaPosted on 2004-10-11 at 14:20:31ID: 12281198

domj

I didn't mean you to use this as workaround. just as a debugging way to see that the path is built ok and that the file is actually there.
anyway, it looks wierd.
one more test for you. write a hard-coded file path, to a file you KNOW is already there. I mean, make a test. put a "test.html" file in c:\, and write the path "c:\test.html" hard coded in your function. see if that also fails.

supply the feedback and we'll see how we take i forward...

Zvika

 

by: domjPosted on 2004-10-11 at 17:24:39ID: 12282736

Oh, OK. Yeh the path works fine. I have tried replacing the path with another. For some reason IE is blocking any attempt that I make to access the window address object.

Dom

 

by: ZvikaPosted on 2004-10-12 at 00:49:11ID: 12284638

well, 3 more suggestios, long shots in the dark...
1. Maybe the problem is in your target page, and not in the way to it. try to navigate to an empty html page, or a simple one (no frames, no dhtml code).
2. a phenomena i once have - what is the name of the site from which you try to navigate? if the site name contains invaid chars, some IE versions consider the site as "unsafe" and won't redirect.
[another test for option 2 and similar is to put your first page, the one that calls the navigation, on the same local machine.]
3. are you sure the permission denied is on the Navigate function? maybe it something else in your code? (maybe something in the Main function?)

I used the following file:
<html>
<head>
<title>bla</title>
<script language=vbscript>
Set wshell=CreateObject("WScript.Shell")

pcname=Wshell.ExpandEnvironmentStrings("%USERNAME%")
curDir=WShell.ExpandEnvironmentStrings("%Temp%")

Function bla()
      msgBox(CurDir & "\" & pcname & "Report.html")
      window.navigate CurDir & "\" & pcname & "Report.html"
End Function
</script>
</head>
<body onload = "bla()">
</body>
</html>

and it works fine.

last possibility is that something is wrong in your permissions either in the browser properties (do remeber that your code generates ActiveX components that some users don't allow) or the folder properties.

 

by: ZvikaPosted on 2004-11-03 at 04:45:46ID: 12482501

well, domj sisn't say if it helped him, so I can't say "Points to me".
I think that if no comment to him, it will be fair to split them among those who gave some effort.... what say you?

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...