1.

Solve : How can i get a vbscript to write in a text file.?

Answer»

Trying to make a vbscript to write in text file, lets say i have C:\example.txt how can i modify this script to write in that text file?

Dim objFileSystem, objOutputFile
Dim strOutputFile

Const OPEN_FILE_FOR_APPENDING = 8

' generate a filename base on the script name
strOutputFile = "./writefile.out"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
  OPEN_FILE_FOR_APPENDING)

objOutputFile.WriteLine("Hello world (" & Now & ")")
objOutputFile.Close

Set objFileSystem = Nothing

WScript.Quit(0)i am not very good at vb
i think that BC_programmer will help here
but i think you change strOutputFile = "./writefile.out"
to
strOutputFile = "./example.txt"
I somewhat figured it out, it'll add text to the file only if it is near it. For example, if the VBS file was located in my documents folder then the text file i am adding has to be there as well. Is there anyway to change it so it will add text to a file in a different location. Anyone?use the full path. right now your using .\, which means the current directory.That's really weird, i could of swore i tried that and it didn't WORK and then i just tried it again after i read your post and it did.

Well anyway, thanks alot BC!oh yeah, I almost forgot, is this a virus?

ha ha, just kidding.  Quote from: BC_Programmer on August 23, 2009, 04:25:33 PM

oh yeah, I almost forgot, is this a virus?

ha ha, just kidding. 

Whoosh.  I don't get it.I had a long argument in a previous post because some GUY thought i was developing a virus. BC is just messing around. Quote from: shrshr429 on August 23, 2009, 04:39:24 PM
I had a long argument in a previous post because some guy thought i was developing a virus. BC is just messing around.

Ah, you are referring to this thread.

Now I get it.i anoy evreyone
salmon anoys evreyone
salmon anoys me
i anoy salmon so thereThat's not true.

salmon doesn't bother me in the slightest.  I prefer it smoked, but.... Quote from: Quantos on August 23, 2009, 05:07:21 PM
I prefer it smoked, but....
hahaha
thats very funny
and carbon dude DONT get to mad for me GOING off topic again Quote from: smeezekitty on August 23, 2009, 05:05:21 PM
i anoy evreyone
salmon anoys evreyone
salmon anoys me
i anoy salmon so there

What are you saying here ? ? Quote from: patio on August 23, 2009, 06:42:45 PM
What are you saying here ? ?

Something about his Salmon being narcoleptic, I think. But how could you tell anyway- fish don't close their eyes when they fall asleep. Quote from: patio on August 23, 2009, 06:42:45 PM
What are you saying here ? ?

You really want to know?


Discussion

No Comment Found