Computer Hope
Software => Computer software => Topic started by: shrshr429 on August 23, 2009, 03:19:28 PM
-
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. :P
-
oh yeah, I almost forgot, is this a virus?
ha ha, just kidding. :P
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.
-
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 (http://www.computerhope.com/forum/index.php/topic,90294.0/all.html).
Now I get it.
-
i anoy evreyone
salmon anoys evreyone
salmon anoys me
i anoy salmon so there
-
That's not true.
salmon doesn't bother me in the slightest. I prefer it smoked, but....
-
I prefer it smoked, but....
hahaha
thats very funny
and carbon dude dont get to mad for me going off topic again
-
i anoy evreyone
salmon anoys evreyone
salmon anoys me
i anoy salmon so there
What are you saying here ? ?
-
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.
-
What are you saying here ? ?
You really want to know?
-
quantos, if you tell him, this forums will not be 'g' rated anymore ;)
-
so i assume people what i mean