|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - Edit an INI file
Hi all
Newbie here, go easy I'm new to scripting so I'm bumbling my way through. I want to read and edit a line in an INI file and this is what I have now Obviously its wrong as I'm posting so any help would be appriciated dim fso,ostream Set fso=CreateObject("Scripting.FileSystemObject") If fso.FolderExists("c:\test") then Set ostream = fso.Opentextfile("c:\test\cqgclnt.ini") Do until ostream.Close stxt = ostream.WriteLine ("CQGVersion=7x6850") Loop End If I am trying to open the ini file, search for CQGVersion and change the value to another date Any ideas ? Thanks all |
|
#2
|
|||
|
|||
|
Sorry that's not quite right
dim fso,ostream,Edittxt Set fso=CreateObject("Scripting.FileSystemObject") If fso.FolderExists("c:\test") then Set ostream = fso.Opentextfile("c:\test\cqgclnt.ini") Do until ostream.Close Edittxt = ostream.WriteLine ("CQGVersion=7x6850") Loop End If Cheers |
|
#3
|
||||
|
||||
|
You've done fine opening the text file, but there's no need for that Do loop. Also, the way it's written, it would be an endless loop anyway.
What does the line look like that you want to change? Can you post that portion of your INI file?
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#4
|
||||
|
||||
|
the whole logic is wrong.
correct logic would be:
|
|
#5
|
||||
|
||||
|
I found here some nice code that can give you direction:
http://cwashington.netreach.net/dep....asp?Index=1095 look for the function "WriteINIValue". |
|
#6
|
|||
|
|||
|
Quote:
CQGVersion=7x3902 Cheers |
|
#7
|
|||
|
|||
|
cheers for the assistance, and the link
I've had a look and I must admit for a new boy to scripting its hard but I'll try and work myway through it |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > VBScript - Edit an INI file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|