Answered by:
VBS to a read a ini file value and then appends the changes in that ini file

Question
-
I am new to VBS and require you assistance.
I have ini file having following fields.
[]
Address=
value=
Now my requirement is to read this ini file and then give a popup box to user to input the address and then value.
By clicking Ok button that value should store in the ini file for example.
Address=abc
Please kindly advise .
Umeed4u
Tuesday, March 1, 2016 12:36 PM
Answers
-
Hi,
You've already posted in the appropriate forum:
EDIT: Two suggestions though. First, you should switch the thread type over to Question instead of Discussion. Second, you should post what code you've already written and what problems you're having with it. If you don't, you'll likely just be pointed at the sticky post at the top of the forum:
- Edited by Mike Laughlin Tuesday, March 1, 2016 12:52 PM
- Proposed as answer by Dave PatrickMVP Tuesday, March 1, 2016 1:39 PM
- Marked as answer by Just Karl Tuesday, March 8, 2016 5:19 PM
Tuesday, March 1, 2016 12:42 PM
All replies
-
Hi,
You've already posted in the appropriate forum:
EDIT: Two suggestions though. First, you should switch the thread type over to Question instead of Discussion. Second, you should post what code you've already written and what problems you're having with it. If you don't, you'll likely just be pointed at the sticky post at the top of the forum:
- Edited by Mike Laughlin Tuesday, March 1, 2016 12:52 PM
- Proposed as answer by Dave PatrickMVP Tuesday, March 1, 2016 1:39 PM
- Marked as answer by Just Karl Tuesday, March 8, 2016 5:19 PM
Tuesday, March 1, 2016 12:42 PM -
0
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set objShell = Wscript.CreateObject("Wscript.Shell")
Const FORREADING = 1
Const FORWRITING = 2
Const FORAPPENDING = 8
Dim sToSearch: sToSearch = "Address="
Dim sFileName: sFileName = "C:\temp\1.ini"
Dim sContent, Found
If Not objFSO.FileExists(sFileName) Then
MsgBox "File Not Found"
WScript.Quit 0
End If
Set TxtFile = objFSO.OpenTextFile(sFileName,FORREADING)
sContent = TxtFile.ReadAll
If InStr(sContent,sToSearch) Then
Found = True
MsgBox "Found"
For i = 1 to 4
TxtFile.ReadLine
Next
strLine = TxtFile.ReadLine
Wscript.Echo strLine
sToSearched = InputBox("Enter your name")
Set TxtFile = objFSO.OpenTextFile(sFileName,FORAPPENDING)
TxtFile.Writeline sToSearch & sToSearched
End If
Set TxtFile = Nothing
If Not Found Then
Set TxtFile = objFSO.OpenTextFile(sFileName,FORAPPENDING)
TxtFile.WriteLine sToSearch
End If
Umeed4u
Tuesday, March 1, 2016 1:58 PM -
Please suggest on the above code..
Umeed4u
Tuesday, March 1, 2016 2:01 PM -