PDA

View Full Version : vbscript in an hta: Abject object


tinyang
04-30-2003, 10:47 AM
Hello. I have a script wrapped in an hta in which I keep getting a Permission Denied error when trying to open a text file for reading on my C drive. I have administrative permissions for my login, and I have checked the permissions on the folder(s) the file is in and I have also ensured the file isn't marked for read only. I have also deleted the file and ran the script again so it would recreate the file a new, but same thing. This hta runs on a local file server and resides in a folder which everyone has full permissions to. It is on a page in our intranet. I'm not sure, but mabey becuase this script uses mshta.exe instead of wscript.exe is why I get this error? See the code snippit below, and thanks in advance for any help.

sub filespec()
'On error resume next
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Set objFS = CreateObject("scripting.FileSystemObject")
set iFile = objFS.opentextfile ("c:\miffed\remsinv\appPaths.txt", ForReading, FailIfNotExist, OpenAsASCII) 'this is where I get the error
Set objFile2 = objFS.CreateTextFile "c:\miffed\remsinv\appver.txt",True)

Do While Not iFile.AtEndOfStream
str = iFile.ReadLine
Set f = objFS.getfile(str)
objFile2.WriteLine("Name: " & f.Name)
objFile2.WriteLine("Version: " & objFS.getfileversion(f))
objFile2.WriteLine("Created: " & f.datecreated)
objFile2.WriteLine("Date Last Modified: " &
f.datelastmodified)
objFile2.WriteLine("Path: " & f.Path)
objFile2.WriteLine("Size: " & f.Size)
objFile2.WriteLine(" ")
Loop
End Sub