Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any VBScript guys out there? i need some help!

Status
Not open for further replies.

mijulie

Programmer
Jun 21, 2001
36
0
0
IE
I got this from the FAQ on reading/writing to textfiles but when i insert it in my code, i get a runtime error pointing to Server.MapPath. Does anyone know exactly what i should put there.:-(

dim fsoObj, sFileName, objtextFile
sFileName = Server.MapPath("writeToThisFile.txt")
set fsoObj = Server.CreateObject("Scripting.FileSystemObject")
set objtextFile = fsoObj.OpenTextFile(sFileName, 8)
objTextFile.WriteLine ("Hello world")
objTextFile.Close
set objTextFile = nothing
set fsoObj = nothing
 
Sorry i forgot to include that the error said,
Object required:"Server"
 
I tried PWS, didn't seem to have any luck there though. I presume it's IIS but i must admit i don't know what that stands for!
 
Hello,
It seems that you put the code between
<script language=&quot;VBScript&quot;> and </script> tags.
This means taht you are doing some client-side processing.
You have to put the code between <% and %> and save file as asp.
Read the faq333-504 to the bottom with very important info for writing privileges.
Hope this helps.
D.
 
By the way, I have Apache installed but haven't used it yet (it seems complicated). Would that make things any easier?
 
Are you trying to execute an ASP page or just an script in HTML?
 
Well, if you don't know much about Apache, it definitely won't help you out here. It won't even parse VBscript without some work.

IIS stands for Internet Information Server, I believe. I have too many acronyms floating around in my head... If you ever need to reference an acronym or find out what something is, check out &quot;It's easier to ask forgiveness than it is to get permission.&quot; - Rear Admiral Dr. Grace Hopper
 
Then You have to use HTML scripts like not Server.CreateObject because this is in ASP pages


Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f1 = fso.CreateTextFile(&quot;c:\testfile.txt&quot;, True)
 
The user should be able to append to the file which would be stored on the Server. I have used just a HTML page and all seems to be working fine, i can write text to a file now. My only problem is how to pass the variable to the textfile as opposed to just a value. I need to know the format for this!
 
Not to worry i figured it out thanks to link9!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top