'Drop an ini file name onto VBS file icon. Edits contents as either ASCII or Unicode text format If Wscript.Arguments.Count<>1 then Wscript.Quit Set objFSO= CreateObject("Scripting.FileSystemObject") IniFile=WScript.Arguments(0) UTF=-1 : Set myFile =objFSO.OpenTextFile (IniFile, 1, False, UTF) 'Assume to be UTF and open content=myFile.ReadAll : myFile.close 'Read whole file in UTF If instr(content,vbCrLf)=0 then UTF=0 : Set myFile =objFSO.OpenTextFile (IniFile, 1, False, UTF) 'Not UTF so open as ASCII Content=myFile.ReadAll : myfile.close 'Read whole file in ASCII End If Edit_ini Content,"WinPosition","Maximized=1" : Edit_ini Content,"Viewing","ViewAll=0" Set myFile =objFSO.OpenTextFile (IniFile, 2, False, UTF) 'Open for writing as original type myFile.write content : myFile.close 'Write whole file as original type Set ObjFSO=Nothing : WScript.Quit Sub Edit_ini (strAll,header,entry) Eq=Instr(1,entry,"=") : key=left(entry,Eq) : header= "[" & header & "]" b1=instr(strAll,header) If b1=0 then strAll=strAll & header &vbCrLf & entry &vbCrLf else b2=instr(b1+1,strAll & "[",vbCrLf&"[") : e1=instr(b1,strAll,key) If e1=0 then strAll=left(strAll,b2+1) & entry & right(strAll,len(strAll)-b2+1) else e2=instr(e1,strAll,vbCrLf) : old_entry = mid(strAll,e1,e2-e1) strAll=replace(strAll,old_entry,entry) End If End If End sub