Hi All,
I want to update a specific line (say line 4) in a text file with the computer name. So in my text file I have:
Computername=changeme
I don't want to append a line at the top or the bottom of the text file. My code would imply I wish to append a line, but that is not what I want. I know this code is not close to being correct, but after wrestling with it I threw in the towel. Here it is in its present form.
Const ForAppending = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = Createobject("Wscript.Network")
strComputerName = WSHNetwork.Computername
Set objFile = objFSO.OpenTextFile("c:\computername.txt", ForAppending)
objFile.WriteLine Now "Computername=" & strComputername
objFile.Close
Thanks.
I want to update a specific line (say line 4) in a text file with the computer name. So in my text file I have:
Computername=changeme
I don't want to append a line at the top or the bottom of the text file. My code would imply I wish to append a line, but that is not what I want. I know this code is not close to being correct, but after wrestling with it I threw in the towel. Here it is in its present form.
Const ForAppending = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = Createobject("Wscript.Network")
strComputerName = WSHNetwork.Computername
Set objFile = objFSO.OpenTextFile("c:\computername.txt", ForAppending)
objFile.WriteLine Now "Computername=" & strComputername
objFile.Close
Thanks.