PDA

View Full Version : Reading files (W98)



meteor0exe
02-03-2004, 02:02 PM
Is there a way to read and .ini file with Windows Script? I'm working on a program to update the virus software everytime a user connects to a network and I was wondering if I was able to do it with WS? If not, please tell me a better language. Thank you in advance.

dineshcooper
02-15-2004, 08:59 AM
Hi

Yes, it can be done using wsh and vbscript.
you would open the file, do your processing, close the file.

this can be done using vbscript:
'reading a file
Set fso_obj = CreateObject("Scripting.FileSystemObject")
If (fso_obj.FileExists("c:\myfile.ini")) Then
Set ini_file = fso_obj.OpenTextFile("c:\myfile.ini", 2)
End If

'writing to file
Set fso_obj = CreateObject("Scripting.FileSystemObject")
If (fso_obj.FileExists("c:\mylog.txt")) Then
Set ini_file = fso_obj.OpenTextFile("c:\mylog.txt", 8)
End If

now that you have your file open do whatever processing you want to and close the file using
ini_file.Close

hope this helps, if you need help with the processing part you should find good info in any vbscript tutorial, my fav is:
http://www.w3schools.com/vbscript