Tuesday, 15 March 2011

Writing to specific location of .txt using vbscript -



Writing to specific location of .txt using vbscript -

can please allow me know how write notepad file has multiple contents, , need write output particular place.

say ex:- have notepad contents

system name=abc123_1223 system_ip=xxx.xx.xxx.xxx domain_name= ??

now need update domain name can from

set info = createobject("adsysteminfo") getdomainname = info.domaindnsname

is there way?

you read content of file variable:

data = fso.opentextfile("c:\path\to\your.txt").readall

replace line regular expression:

set re = new regexp re.pattern = "^(domain_name=).*" re.ignorecase = true re.multiline = true info = re.replace(data, "$1" & info.domaindnsname)

then write modified info file:

fso.opentextfile("c:\path\to\your.txt", 2).write info

vbscript

No comments:

Post a Comment