While the code below works perfect in VB, it returns "Permission denied" when I run it through my web-server (page.asp).
Info:
- Windows XP
- Script enabled in the virtual folder
- No NTFS
- Even tried to put IUSR_..... in Administrators
I'm probably missing something basic. Have anyone got any ideas?
Regards.
Erik
Code:
Dim fso
Dim textstream
Set fso = CreateObject("Scripting.FileSystemObject")
Set textstream = fso.OpenTextFile("C:\Temp\test.txt", 2)
textstream.Write "hello"
An Asp page is running in IIS as some user (usually Anonimous or Guest or User).
You have two choices:
The dangerous one is: run your asp as user with permission to write on server (really not encouraged!)
The safer one is: build a Com+ component, which may run even as Administrator, if you want, that has a method with those instructions. Via Asp page, you use createObject to instantiate that component, and use the method (yes, you can pass parameters, and even get a value back or change byref parameters) to read - write files....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
I've already tried the first alternative, and it didn't help.
The strange thing is that I get the exact same code to work (via IIS) on a Windows 2000 Server. But not on my or my friends machine that both are running Windows XP.
Do you know if there any changes in file access from 2000 to XP?
Reading the file works fine. But not opening it for writing.
Sorry, I do not work with Xp...
You sure interactive user has permission to write? You sure the virtual dir has been set with permission to write (IIS settings)?
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The folder C:\Temp must be visible from the Virtual directory - if you are trying to write somewhere other than the virtual directory or one of the sub-folders, you are always going to get into trouble....
XP has a lot of protection switched ON by default (the opposite to what we're all used to).
Change the file that you're writing to, to something that can be seen by the virtual directory....see if that works. (I'll assume that you've already tried that, and it works.)
I don't think that IIS can write to anywhere other than a virtual directory. I have had to reverse map drives on a protected FTP server to get things writeable.
Good luck....and if you're not bald already, you will be by the time you figure IIS out
Bookmarks