如何创建vbscript或bat文件以覆盖现有xml文件
我们应用程序的一个用户在如何创建vbscript或bat文件以覆盖现有xml文件,xml,vbscript,batch-file,Xml,Vbscript,Batch File,我们应用程序的一个用户在C:\ProgramData\Secon\levrer\8.6.7\team\lead\Captain文件夹中有一个名为zean.xml的xml文件。但现在我觉得我需要用以下内容替换xml文件内容,作为临时解决办法。我想编写vbscript或bat文件,以便能够提供给使用此xml文件的用户。任何人都可以为我提供vbscript代码或bat文件,用于重写包含以下内容的xml文件吗 <?xml version="1.0" standalone="yes" ?>
C:\ProgramData\Secon\levrer\8.6.7\team\lead\Captain文件夹中有一个名为zean.xml
的xml文件。但现在我觉得我需要用以下内容替换xml文件内容,作为临时解决办法。我想编写vbscript或bat文件,以便能够提供给使用此xml文件的用户。任何人都可以为我提供vbscript代码或bat文件,用于重写包含以下内容的xml文件吗
<?xml version="1.0" standalone="yes" ?>
<TestSchema xmlns="http://tempuri.org/TestSchema.xsd">
<UserZone>
<Label>All</Label>
<ID>8c19c791-32d6-4ad1-8504-c3387b5a0096</ID>
</UserZone>
<ZoneMgGrpCollection>
<Owner>8c19c791-32d6-4ad1-8504-c3387b5a0096</Owner>
<MgGrpID>5f498b70-ee75-4ff0-8808-b9ba492b7f8a</MgGrpID>
</ZoneMgGrpCollection>
</TestSchema>
全部的
8c19c791-32d6-4ad1-8504-c3387b5a0096
8c19c791-32d6-4ad1-8504-c3387b5a0096
5f498b70-ee75-4ff0-8808-b9ba492b7f8a
只需将文本添加到新的XML文件中,然后将其复制到另一个XML文件上即可。
您可以手动或通过脚本进行操作,但我不明白为什么要通过脚本进行操作,因为这显然是一次性操作
Const ForReading = 1, ForWriting = 2, ForAppending = 8, CreateIfNeeded = true
Set fso = CreateObject("Scripting.FileSystemObject")
set tf=fso.OpenTextFile ("new.xml",ForWriting,CreateIfNeeded)
tf.write "<?xml version=""1.0"" standalone=""yes"" ?> "
'repeat this for the other lines
tf.close
fso.CopyFile("new.xml", "C:\ProgramData\Secon\levrer\8.6.7\team\lead\Captain folder\",True)
Const ForReading=1,forwrite=2,ForAppending=8,CreateIfNeeded=true
设置fso=CreateObject(“Scripting.FileSystemObject”)
设置tf=fso.OpenTextFile(“new.xml”,用于写入,CreateIfNeeded)
tf.write“”
'对其他行重复此操作
关闭
CopyFile(“new.xml”,“C:\ProgramData\Secon\levrer\8.6.7\team\lead\Captain folder\”,True)