动态生成MSI包的WIX脚本文件内容

生成MSI脚本批命令
例如1:
set wixpath=G:\U8V13.1安装程序包\Wix
set packpath="G:\U8V13.1安装程序包\所有补丁文件包"
set packname=U8ERP-User-Define2
pushd %wixpath%
C:\Windows\system32\cscript /NoLogo %wixpath%\DEFINEWixcreater.vbs %packpath%\Define2Tobeinstall %packpath%\%packname%.wxs /Name %packname% /SPID %packname% /RegVersion V8.700 /ID a0000000-0000-0000-0000-000000000002 /Packageid a0000000-0000-0000-0000-000000000002 /RESTOREDISABLED /FORCEREBOOT

candle -nologo -sw1044 -sw1031 -out %packpath%\%packname%.wixobj %packpath%\%packname%.wxs

Light -nologo -out %packpath%\%packname%.msi %packpath%\%packname%.wixobj

del /f/s/q H:\制作HotFix大包\U8ERP-User-Define2.wixobj
del /f/s/q H:\制作HotFix大包\U8ERP-User-Define2.wxs
例如2:
cscript.exe   /NoLogo H:\U813.1_SOURCE\打所有包的目录\Wix\\Wixcreater.vbs H:\U813.1_SOURCE\package\MSIOBJ\uap H:\U813.1_SOURCE\package\MSI\U8ERP-PUBLIC-UAP.wxs /Name U8ERP-PUBLIC-UAP /SPID U8ERP-PUBLIC-UAP /RegVersion V8.700 /ID 2166c7c8-b032-4a45-8c47-88ed6270bc5f /PackageID 2166c7c8-b032-4a45-8c47-88ed6270bc5f /FORCEREBOOT /RESTOREDISABLED

candle.exe -nologo -sw1044 -sw1031 -out "H:\U813.1_SOURCE\package\MSI\U8ERP-PUBLIC-UAP.wixobj" "H:\U813.1_SOURCE\package\MSI\U8ERP-PUBLIC-UAP.wxs"

Light.exe -nologo -out H:\U813.1_SOURCE\package\MSI\U8ERP-PUBLIC-UAP.msi H:\U813.1_SOURCE\package\MSI\U8ERP-PUBLIC-UAP.wixobj

Wixcreater.vbs 文件内容

''''''''''''''''''''''''''''''''''''
'
' BuildMSI.vbs 
'
' KENLY
' Date: Nov.16.2005 
' Copyright(c) 1988-2005 UFIDA.Inc,Ltd.
'
' Revision History:
'     Date         Comment
'
' 根据相关信息,自动生成Wix源文件,然后调用Wix toolSet
' 自动生成MSI适合U8补丁包安装文件
' 
' 
''''''''''''''''''''''''''''''''''''
Option Explicit
'On Error Resume Next




dim productName			' 产品名称
dim productId			' 产品ID
dim productManufacturer	' 生产产商
dim productVersion		' 产品版本 格式为xx.xx.xx.xx
dim productLanguage		' 语言
dim productUpgradeCode	' 升级ID	


dim packageID			' PackageID
dim packageKeywords		' 关健字
dim packageDescription	' 说明
dim packageComment		' 意见
dim installVersion		' MSI安装程序版本
dim codepage			' 代码页
dim Compressed			'
dim SummaryCodepage
dim Platforms


dim spid				' KB 问题号
dim regVersionKey			'
dim regKeyPath
dim regGuidPath           'GUID 设置 




dim DomObject			'
dim ndProduct			
dim ndUI
dim ndrootDirectory		
dim sourceDirectory
dim outwixfilename
dim licencefile			' 许可文件Path
dim envCheckfile			' 环境检测的配置文件路径
dim serviceControlFile                  '控制服务的配置文件
dim fso					' Scripting.FileSystemObject对象
dim dict				'记录CustomAction
Dim dictdeferca         '记录延迟的CustomAction
dim dictbefore				'记录安装前的CustomAction
dim dependchecklist		' 依赖补丁的ID,多个用逗号分隔


dim arrSystemFolders()
dim arrMyCatalog()
dim disabledRollback
dim RestoreDisabled      ' 卸载的时候是否支持恢复老版本=true,禁止恢复
dim filecount
dim forceReboot			' 安装包完成后是否强制重启系统 ,=true 强制重启
dim justuap				'
dim file_gacutil        '记录需要注册到全局程序级的文件
dim file_regasm         '记录使用REGASM导出程序集tlb文件,并注册的文件集
dim file_regasm40         '记录使用REGASM v4.0.30319版本导出程序集tlb文件,并注册的文件集
dim file_regsvcs        '记录需要COM+注册的文件集
dim file_regserver      '记录需要使用/RegServer或-RegServer注册的文件集
dim file_regsvr32      '记录需要使用regsvr32注册的文件集,通常用于msi无法正常注册的com组件
dim DBEnginSysPath      '记录DBEngin的路径
dim SQLITERUNSysPath    '记录SQLLite导入数据库的路径
dim AFTERRUNSysPath     '记录SQLLite卸载数据库的路径
dim cataSetupType
CONST CATA_OTHERS	= 0		' 一般的目录
CONST CATA_COM		= 1		' 需要regsvr32注册的
CONST CATA_COMPLUS	= 2		' 需要COM+注册
CONST CATA_NET		= 3		' 需要.Net注册
CONST CATA_RUN		= 4		' 安装完成后需要进行的组件
CONST CATA_SERVICE	= 5		' 服务安装类型
CONST CATA_SPF		= 6		' Windows SPF文件
CONST CATA_RUNONCE  = 7		' 安装完后重起自动运行一次
CONST CATA_WEBVIRTUAL = 8	 ' Web Virtual Directory
CONST CATA_NETREGASM  = 9	' 使用REGASM导出程序集tlb文件,并注册
CONST CATA_NETBOTH	= 10	' 同时注册到GAC,并且使用REGASM注册


CONST CATA_APP	= 11		' 应用服务器
CONST CATA_CLIENT	= 12		'客户端
CONST CATA_DB	= 13		'数据库服务器
CONST CATA_REMOVE   =14         '需要删除的目录
CONST CATA_REGSERVER   =15      'COM组件(EXE),使用/RegServer或-RegServer注册
CONST CATA_REGISTRY   =16       '需要写在注册表中的注册键值
CONST CATA_WEB	= 17		'Web服务器
CONST CATA_LS	= 18		'license server 服务器
CONST CATA_COMMONAD	= 19		'数据库服务器或者应用服务器
CONST CATA_REGSVR32   =20      'COM组件,使用regsvr32 注册,主要针对一些经常注册不成功的com组件
CONST CATA_NOTUNINSTALL   =21	'卸载时不删除的文件 add by lilf
CONST CATA_NOTUNINSTALLCOM		= 22		' 需要regsvr32注册的且卸载不删除文件 add by lilf
CONST CATA_RUNWITHARGSP = 23		' 安装后运行EXE 传递MSI包的名称 EXE名称固定为SetPatchInfoToSqlLite.exe 才执行  add by lilf
CONST CATA_RUNAFTERREMOVE = 24		' 卸载后运行EXE 传递MSI包的名称 EXE名称固定为SetPatchInfoToSqlLite.exe 才执行 add by lilf
CONST CATA_RUNUNINSTALL = 25        ' 卸载后运行EXE 直接的运行,不做任何处理。 add by lilf
CONST CATA_COMMON = 26  '所有安装方式都安装的模式add by lilf
CONST CATA_RUNBEFORE = 28		' 安装前需要进行的组件 add by lilf
CONST CATA_NETREGASM40  = 29	' 使用REGASM.exe此是v4.0.30319版本的导出程序集tlb文件,并注册
const ForReading = 1
CONST REG_RUNONCE_KEYPATH = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
CONST REINSTALLMODE ="emus"     '重安装类型 =emus 按版本控制 ;=amus 强迫所有文件无条件安装


''''''''''''''''''''''''''''''''''''
' Main Entry Point
''''''''''''''''''''''''''''''''''''


CALL Main


''''''''''''''''''''''''''''''''''''
' END Main Entry Point 
''''''''''''''''''''''''''''''''''




''''''''''''''''''''''''''''''''''''
' Main Function
''''''''''''''''''''''''''''''''''''
Function Main()
	Call INIT
	If Not ProcessCommandLine Then
		Exit Function
	End If


	CALL CreateWixSourceFile
	DOMObject.Save outwixfilename


End Function


''''''''''''''''''''''''''''''''''''
'
' 处理命令行参数
'
' 读取命令行参数,并解析初始化相关变
' 量值
'
''''''''''''''''''''''''''''''''''''
Function ProcessCommandLine()
	dim args
	dim i
	dim count
	dim bregKeyPath '是否已经指定完整的注册键值
	set args = WScript.Arguments


	ndrootDirectory = ""
	outwixfilename	= ""
	bregKeyPath=false


	count = 0
	If args.Count < 2 Then
		Call DisplayUsageMessage
		ProcessCommandLine = FALSE
		Exit Function
	End If


	For i=0 to args.Count - 1
		Select case Ucase(args(i))
		Case "/NAME","-NAME"
			i = i+1
			productName = args(i)
		Case "/ID","-ID"
			i = i+1
			productId = args(i)			
		Case "/VENDOR","-VENDOR"
			i = i+1
			productManufacturer = args(i)
		Case "/VERSION","-VERSION"
			i = i+1
			productVersion = args(i)
		Case "/LANG","-LANG"
			i = i+1
			productLanguage = args(i)
		Case "/UPID","-UPID"
			i = i+1
			productUpgradeCode = args(i)
		Case "/PACKAGEID","-PACKAGEID"
			i = i+1
			packageID = args(i)
		Case "/KEYWORDS","-KEYWORDS"
			i = i+1
			packageKeywords = args(i)
		Case "/DESCRIPTION","-DESCRIPTION"
			i = i+1
			packageDescription = args(i)
		Case "/COMMENT","-COMMENT"
			i = i+1
			packageComment = args(i)
		Case "/MSIV", "-MSIV"
			i = i+1
			installVersion = args(i)
		Case "/CODEPAGE","-CODEPAGE"
			i = i+1
			codepage = args(i)
		Case "/SPID","-SPID"
			i = i+1
			spid = args(i)
			regKeyPath = regKeyPath & spid
		Case "/REGVERSION","-REGVERSION"
			i = i+1
			regVersionKey = args(i)
		Case "/FULLREGPATH","-FULLREGPATH"
			i = i+1
			regKeyPath = args(i)
			bregKeyPath=true
		Case "/LICENCEFILE", "-LICENCEFILE", "/L", "-L"
			i = i+1
			licencefile = args(i)
		Case "/DEPENDLIST", "-DEPENDLIST", "/D", "-D"
			i = i+1
			dependchecklist = args(i)
		Case "/ENVCHECKFILE", "-ENVCHECKFILE"
			i = i+1
			envCheckfile= args(i)
		Case "/FORCEREBOOT", "-FORCEREBOOT"
			forceReboot=True
		Case "/RESTOREDISABLED", "-RESTOREDISABLED"
			RestoreDisabled=True
		Case Else
			count = count + 1
			If count = 1 Then sourceDirectory = CStr(args(i))
			If count = 2 Then outwixfilename  = CStr(args(i))
		End Select
	Next


	If sourceDirectory = "" Or outwixfilename = "" Then
		Call DisplayUsageMessage
		ProcessCommandLine = FALSE
		Exit Function
	End If
	
	if bregKeyPath=false then
		regKeyPath="SOFTWARE\Ufsoft\WF\" + regVersionKey + "\SPINFO\" + spid
	end if
	
	
	ProcessCommandLine = TRUE
End Function


''''''''''''''''''''''''''''''''''''
' 
' 显示使用帮助信息
' 
''''''''''''''''''''''''''''''''''''
Sub DisplayUsageMessage()
	Wscript.Echo "Copyright(c) 1988-2005 UFIDA.Inc.Ltd,"
	Wscript.Echo ""
    WScript.Echo "Usage:"
    WScript.Echo "      CScript Wixcreater.VBS [[/|-]option] <Source Path> <Output File Name>"
	WScript.Echo "															  "
	WScript.Echo "Options:"
	WScript.Echo "		/Name <Product Name>"
	WScript.Echo "		/Id <Product Id> a unique identifier for the particular product release"
	WScript.Echo "		/Vendor			<Manufacturer>"
	WScript.Echo "		/Version		<Product Version>"
	WScript.Echo "		/Lang			<Product Language>"
	WScript.Echo "		/UpId			<UpgradeCode> a unique identifier"
	WScript.Echo "		/PackageId		<GUID for PackageId>"
	WScript.Echo "		/Keywords		<Keywords for this Install package>"
	WScript.Echo "		/Description	<Description for this Install package>"
	WScript.Echo "		/Comment		<Comment for this install package>"
	WScript.Echo "		/MSIV			<Windows Install version>"
	WScript.Echo "		/CodePage		<Codepage for this Install package>"
	WScript.Echo "		/SPID			<UFIDA Support KB Number>"
	WScript.Echo "		/RegVersion		<UFIDA U8 Product Register Key(e.g. V8.600)>"
	Wscript.Echo "		/FullRegPath	<UFIDA U8 Product Full Register Key Path>"
	Wscript.Echo "		/LICENCEFILE	<Licence file Path>"
	Wscript.Echo "		/DEPENDLIST		Depend SPID List, use comma split"
	Wscript.Echo "		/ENVCHECKFILE	<enviroment check file  Path>"
	Wscript.Echo "		/FORCEREBOOT	prompts the user for a reboot of the system at the end of installation"
	Wscript.Echo "		/RESTOREDISABLED        Disabled to restore the files during uninstalling  "
    WScript.Echo
End Sub




''''''''''''''''''''''''''''''''''''
' 
' 创建Wix源文件的入口点
' 
''''''''''''''''''''''''''''''''''''
Function CreateWixSourceFile()
	Call processProductNode
	Call processPackageNode
	Call processUpgradeNode
	Call AddConditionNode(ndProduct, _
			"Version9X OR ((VersionNT > 400) OR ((VersionNT = 400) AND (ServicePackLevel >= 6)))", _
			"[ProductName] 无法安装在 [WindowsTypeNT] 或更早的版本")


	Call processMedia
	Call ProcessRootDirectory
	Call ProcessRootDriveProperty 
	CALL processBackupDirectory(ndrootDirectory)
	CALL RegisterSPInfo
	CALL RegisterGUIDInfo
	Call processFolder(sourceDirectory, 0, ndrootDirectory, NOTHING, "", "")
	Call ProcessCustomProperty(ndProduct)
    Call ProcessCustomPropertyAction(ndProduct)
	Call processUIs
	Call processInstallExecuteSequence
	Call ProcessPropertys
	Call processBinary
	Call ProcesslegalFile	
	Call ProcessServiceControlFile
	Call ProcessCustomActionDll(ndProduct,"CAFileDatingRule","check","ufutils","CompareFilesDate","immediate","yes")
	Call ProcessCustomActionDll(ndProduct,"CARemoveFiles","ignore","ufutils","RemoveAllFiles","immediate","yes")
	Call ProcessUninstallCustomAction(ndProduct)
End Function


Function processInstallUISequence(ndparent)
	dim dom
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	If dom.Load("Lib\UISequence.xml") Then
		For Each nd in dom.documentElement.childNodes
			ndParent.appendChild nd
		Next
	End If


	dim ndroot 
	set ndroot = AppendChild(ndProduct, "InstallUISequence")
	set nd = NewChild(ndroot, "Custom")
	nd.setAttribute "Action", "CARootDrive"	
	nd.setAttribute "Before", "AppSearch"
End Function


Function GetDirecotryCatalogType(dirName)
	Select case UCase(dirName)
	case "COM"
		GetDirecotryCatalogType = CATA_COM
	case "COMPLUS"
		GetDirecotryCatalogType = CATA_COMPLUS
	case "NET"
		GetDirecotryCatalogType = CATA_NET
	case "RUN"
		GetDirecotryCatalogType = CATA_RUN
	case "RUNBEFORE"
		GetDirecotryCatalogType = CATA_RUNBEFORE		
	case "RUNWITHARGSP"
		GetDirecotryCatalogType = CATA_RUNWITHARGSP
	case "RUNAFTERREMOVE"
		GetDirecotryCatalogType = CATA_RUNAFTERREMOVE
	case "RUNUNINSTALL"
		GetDirecotryCatalogType = CATA_RUNUNINSTALL
	case "SERVICE"
		GetDirecotryCatalogType = CATA_SERVICE
	case "SPF"
		GetDirecotryCatalogType = CATA_SPF
	case "RUNONCE"
		GetDirecotryCatalogType = CATA_RUNONCE
	case "WEBDIR"
		GetDirecotryCatalogType = CATA_WEBVIRTUAL
	case "NETREGASM","NETWITHOUTGAC"
		GetDirecotryCatalogType = CATA_NETREGASM
	case "NETREGASM40"
		GetDirecotryCatalogType = CATA_NETREGASM40		
	case "NETBOTH"
		GetDirecotryCatalogType = CATA_NETBOTH
        case "REMOVE"
		GetDirecotryCatalogType = CATA_REMOVE
	case "REGSERVER"
		GetDirecotryCatalogType = CATA_REGSERVER
	case "REGISTRY"
		GetDirecotryCatalogType = CATA_REGISTRY
	case "REGSVR32"
		GetDirecotryCatalogType = CATA_REGSVR32
	case "NOTUNINSTALL" 
		GetDirecotryCatalogType = CATA_NOTUNINSTALL
	case "NOTUNINSTALLCOM" 
		GetDirecotryCatalogType = CATA_NOTUNINSTALLCOM
	case else	' Others
		GetDirecotryCatalogType = CATA_OTHERS
	End Select
End Function


Function processInstallExecuteSequence()
	dim ndroot
	dim nd
	dim i
	dim ndcdata
	dim items
	dim lastsequence




	set ndroot = AppendChild(ndProduct, "InstallExecuteSequence")


	set nd = NewChild(ndroot, "RemoveExistingProducts")
	nd.setAttribute "After", "InstallValidate"
	
	set nd = NewChild(ndroot, "AppSearch")
	nd.setAttribute "Before", "LaunchConditions"


	set nd = NewChild(ndroot, "Custom")
	nd.setAttribute "Action", "CARemoveFiles"
	'nd.setAttribute "Before", "CARollbackFiles"
	nd.setAttribute "After", "InstallFinalize"	
	Set ndcdata = NewChildEx(nd, "Custom",4)
	ndcdata.text = "REMOVE = ""ALL"" AND CAREMOVE=""ALL"""


	


	set nd = NewChild(ndroot, "Custom")
	nd.setAttribute "Action", "CARollbackFiles"
	nd.setAttribute "After", "CARemoveFiles"
	Set ndcdata = NewChildEx(nd, "Custom",4)
	ndcdata.text = "REMOVE = ""ALL"""


	set nd = NewChild(ndroot, "MoveFiles")
	Set ndcdata = NewChildEx(nd, "MoveFiles",4)
	ndcdata.text = "ProductState = -1"
	
	set nd = NewChild(ndroot, "RemoveFiles")
	Set ndcdata = NewChildEx(nd, "RemoveFiles",4)
	ndcdata.text = "CAREMOVE="""""	


	set nd = NewChild(ndroot, "InstallValidate")
	Set ndcdata = NewChildEx(nd, "InstallValidate",4)
	ndcdata.text = "CAREMOVE="""""		
	if REINSTALLMODE  <>"amus" then
		set nd = NewChild(ndroot, "Custom")
		nd.setAttribute "Action", "CAFileDatingRule"
		nd.setAttribute "After", "CostFinalize"	
		Set ndcdata = NewChildEx(nd, "Custom",4)
		'ndcdata.text = "CADEPEND=1"
		'ndcdata.text = "REINSTALLMODE <>""amus"""
	end if
	'安装前调用事件
	items=dictbefore.items
	lastsequence = "InstallValidate"
	For i = dictbefore.Count -1 to  0 Step -1
		set nd = NewChild(ndroot, "Custom")  
		nd.setAttribute "Action", items(i)
		nd.setAttribute "After", lastsequence
		Set ndcdata = NewChildEx(nd, "Custom",4)
	    ndcdata.text = "ProductState = -1"
		lastsequence=items(i)
	Next
	items=dictdeferca.items
	lastsequence = "InstallFinalize"
	For i = dictdeferca.Count -1 to  0 Step -1
		set nd = NewChild(ndroot, "Custom")  
		nd.setAttribute "Action", items(i)
		nd.setAttribute "Before", lastsequence 		
		lastsequence=items(i)
	Next


	lastsequence = "CARollbackFiles"
	if forceReboot then
		set nd = NewChild(ndroot, "ScheduleReboot")
		nd.setAttribute "After", lastsequence
		Set ndcdata = NewChildEx(nd, "Custom",4)
		ndcdata.text = "FAPPEC <> """""
		lastsequence = "ScheduleReboot"
	end if


	items = dict.items
	For i = 0 to dict.Count -1
		set nd = NewChild(ndroot, "Custom")                
        dim arr
        arr=split(items(i),"#") 		
		nd.setAttribute "Action", arr(0)
		nd.setAttribute "After", lastsequence


		Set ndcdata = NewChildEx(nd, "Custom",4)                
		
		if arr(0)="errDBEnginSys" then
			ndcdata.text = "EXCUTEDBENGINSYS = ""0"""		
		elseif arr(0)="CACustomAction_CreateBinaryFile" then
				ndcdata.text = ""
		elseif arr(0)="errSqlLiteSys" then
				ndcdata.text = "EXCUTESQLLITESYS = ""0"""		
		elseif arr(0)="errExeSys" then
				ndcdata.text = "EXCUTEEXESYS = ""0"""	
		elseif arr(0)="CACustomPropertyAction5" then
				ndcdata.text = "REMOVE = ""ALL"""
		elseif arr(0)="CACustomPropertyAction6" then
				ndcdata.text = "REMOVE = ""ALL"""				
		else			
			 if Ubound(arr)>0 then             
                ndcdata.text = "ProductState = -1 AND " & arr(1) & "<> """""
			 else
			    ndcdata.text = "ProductState = -1"
			end if	                        
		end if			
		lastsequence = arr(0)
	Next


	Set processInstallExecuteSequence = nd
End Function


Function processFeature(id)
	dim nd
	
	Set nd = ndProduct.SelectSingleNode("Feature[@Id='" & id & "']")
	If Not nd is Nothing Then
		Set processFeature = nd
		Exit Function
	End If


	Set nd = NewChild(ndProduct, "Feature")
	
	nd.setAttribute "Id", id
	nd.setAttribute "Title", id
	nd.setAttribute "Description", id
	nd.setAttribute "Display", "expand"
	nd.setAttribute "Level", "1"


	' 增加条件
	Select case Ucase(id)
	Case "APP"
		Call AddConditionNodeEx(nd, _
				"FAPPC=""""", _
				"", _
				"", _
				"0")
		cataSetupType	=CATA_APP
	Case "CLIENT"
		Call AddConditionNodeEx(nd, _
				"FDESC=""""", _
				"", _
				"", _
				"0")
	cataSetupType	=CATA_CLIENT
	Case "DB"
		Call AddConditionNodeEx(nd, _
				"FDBC=""""", _
				"", _
				"", _
				"0")
		cataSetupType	=CATA_DB
        Case "WEB","WEBSERVER"
		Call AddConditionNodeEx(nd, _
				"FWEBC=""""", _
				"", _
				"", _
				"0")
		cataSetupType	=CATA_WEB
	Case "LS"
		Call AddConditionNodeEx(nd, _
				"FLSC=""""", _
				"", _
				"", _
				"0")
		cataSetupType	=CATA_LS
	Case "COMMONAD"
		Call AddConditionNodeEx(nd, _
				"FAPPC="""" OR FDBC=""""", _
				"", _
				"", _
				"0")
		cataSetupType	=CATA_COMMONAD
	Case "COMMON"
	    cataSetupType	=CATA_COMMON
	End Select


	Set processFeature = nd
End Function


Function processDirectory(ndparent,id, name, longname)
	dim nd 


	Set nd = NewChild(ndparent, "Directory")
	nd.setAttribute "Id", id
	nd.setAttribute "Name", name
	If longname<>"" Then nd.setAttribute "LongName", longname
	
	Set processDirectory = nd
End Function


Function processComponentRef(ndfeature, id)
	dim nd 


	Set nd = NewChild(ndfeature, "ComponentRef")
	nd.setAttribute "Id", id


	Set processComponentRef = nd
End Function


Function processComponent(ndparent,id, guid)
	dim nd
	set processComponent = processComponentEx(ndparent,id, guid,"no")


	'set nd = NewChild(ndparent, "Component")
	'nd.setAttribute "Id", id
	'nd.setAttribute "Guid", guid
	'nd.setAttribute "SharedDllRefCount", "yes"
	'Set processComponent = nd
End Function


Function processComponentEx(ndparent,id, guid,Permanent)
	dim nd
	set nd = NewChild(ndparent, "Component")
	nd.setAttribute "Id", id
	nd.setAttribute "Guid", guid
	if Permanent<>"" then nd.setAttribute "Permanent", Permanent
	Set processComponentEx = nd
End Function


Function processProperty(ndparent, id, value)
	dim nd
	dim ndcdata


	Set nd = NewChild(ndparent, "Property")
	nd.setAttribute "Id", id
	
	Set ndcdata = NewChildEx(nd, "Property", 4)
	ndcdata.text = value


	set processProperty = nd
End Function


Function GetGuididentifier(guid)
	GetGuididentifier = Replace(guid, "-", "_")
End Function


Function RegisterSPInfo()
	dim ndcommFeature
	dim ndcomponent
	dim guid
	dim guidreplaced
	


	guid = CreateGUID
	guidreplaced = GetGuididentifier(guid)
	'将注册表的Feature独立出来
	Set ndcommFeature = processFeature("SPINFORegister")
	'Set ndcommFeature = processFeature("COMMON")
	Set ndcomponent   = processComponent(ndrootDirectory, "SPINFORegister" + guidreplaced, guid)
	CALL processRegister(ndcomponent, "SPSIGNED", "HKLM", regKeyPath, "string", productId, "")
	CALL processComponentRef(ndcommFeature, "SPINFORegister" + guidreplaced)
	


	
End Function


	
Function RegisterGUIDInfo()


 	dim ndcommFeature
	dim ndcomponent
	dim guid
	dim guidreplaced
	
   '添加注册表GUID变化项目供智能安装使用
	guid = CreateGUID
	guidreplaced = GetGuididentifier(guid)
	Set ndcommFeature = processFeature("SPGUIDRegister")
	Set ndcomponent  = processComponent(ndrootDirectory, "SPGUIDRegister" + guidreplaced, guid)
	'CALL processRegister(ndcomponent, "SPGUID", "HKLM", regGuidPath, "string", guid, "smartclient")
	CALL processComponentRef(ndcommFeature, "SPGUIDRegister" + guidreplaced)
	
End Function
'自定义的注册表信息
Function RegisterCustomInfo(opt ,freg)
	dim ndcommFeature
	dim ndcomponent
	dim guid
	dim action
	dim guidreplaced
	Dim  arr 
	guid = CreateGUID
	guidreplaced = GetGuididentifier(guid)
	'将注册表的Feature独立出来
	Set ndcommFeature = processFeature("SPINFORegister")
	'Set ndcommFeature = processFeature("COMMON")
	Set ndcomponent   = processComponent(ndrootDirectory, "Reg" & guidreplaced, guid)				    
	arr = Split(freg, vbTab, -1, 1)
	Select case Ucase(opt )
	case "ADD"
		if UBound(arr)<4 then
	      		Wscript.Echo  "addRegistry format wrong.field:"&UBound(arr)		
	   	end if
		CALL processRegister(ndcomponent, "reg" & guidreplaced, arr(0), arr(1), arr(2), arr(4),arr(3))
	case "REMOVE"
		if UBound(arr)<1 then
	      		Wscript.Echo  "removeRegistry format wrong.field:"&UBound(arr)		
	   	end if
		CALL processRemoveRegister(ndcomponent, "reg" & guidreplaced, arr(0), arr(1))
	end select
	
	
	CALL processComponentRef(ndcommFeature, "Reg" & guidreplaced)	
End Function


Function processRegister(ndparent, id, root, key, regtype, value, name)
	dim nd 


	Set nd = NewChild(ndparent, "Registry")
	nd.setAttribute "Id", id
	nd.setAttribute "Root", root
	nd.setAttribute	"Key", key
	nd.setAttribute	"Type", regtype
	If name<> "" Then nd.setAttribute	"Name", name	
	nd.setAttribute	"Value", value


	Set processRegister = nd
End Function


Function processRemoveRegister(ndparent, id, root, key)
	dim nd 
	Set nd = NewChild(ndparent, "Registry")
	nd.setAttribute "Id", id
	nd.setAttribute "Root", root
	nd.setAttribute	"Key", key	
	nd.setAttribute	"Action", "removeKeyOnUninstall"	
	Set processRemoveRegister= nd
End Function


Function processFile(ndparent, id, name, longname, src, vital, keypath, diskid, selfreg,assembly)
	dim nd


	set nd = NewChild(ndparent, "File")
	nd.setAttribute "Id", id
	nd.setAttribute "Name", name
	If longname <> "" Then nd.setAttribute "LongName", longname
	If src <> "" Then nd.setAttribute "src", src
	If vital <> "" Then nd.setAttribute "Vital", vital
	If keypath <> "" Then nd.setAttribute "KeyPath", keypath
	If selfreg <> "" Then nd.setAttribute "SelfRegCost", selfreg
	If diskid <> "" Then nd.setAttribute "DiskId", diskid
	If assembly<>"" Then nd.setAttribute "Assembly", assembly
	
	if justuap = true then
		if name="UAP.exe" then
			dim shortCutNd 
			set shortCutNd = Newchild(nd,"Shortcut")
			shortCutNd.setAttribute "Id",id
			shortCutNd.setAttribute "Advertise","no"
			shortCutNd.setAttribute "Description","二次开发平台"
			shortCutNd.setAttribute "Directory","UAPShortCut"
			shortCutNd.setAttribute "Name",name
			shortCutNd.setAttribute "LongName","UAP开发平台"
			shortCutNd.setAttribute "WorkingDirectory","UAPdir"
		end if
	end if
	
	Set processFile = nd
End Function


Function processRemoveFile(ndparent, id, name, longname, onmode)
	dim nd
	set nd = NewChild(ndparent, "RemoveFile")
	nd.setAttribute "Id", id
	nd.setAttribute "Name", name
	If longname <> "" Then nd.setAttribute "LongName", longname
	If onmode<> "" Then nd.setAttribute "On", onmode	
	Set processRemoveFile = nd
End Function


Function processBackupDirectory(ndparent)
	dim nd
	dim ndchild
	dim comp
	dim guid
	dim guidreplaced
	dim ndFeature


	Set nd		= processDirectory(ndparent, "Backupdir", "UFBAK", "UFUNINSTALL")
	Set ndchild = processDirectory(nd, "currbak", "bak", "$" & productName & "$")


	if justuap = True then
		Set nd		= processDirectory(ndparent, "UAPdir", "UFUAP", "UAP")
		Set ndDesktop = processDirectory(ndparent, "DesktopFolder", "DTFOLDER", "DesktopFolder")
		
		Set ndDesktop = processDirectory(ndparent, "ProgramMenuFolder", "PMenu", "Programs")
		Set ndDesktop = processDirectory(ndDesktop, "U8ShortCut", "U8PMenu", "用友ERP-U8")
		Set ndDesktop = processDirectory(ndDesktop, "UAPShortCut", "UAPPMenu", "UAP")
	end if
End Function


Function processCopyFileEx(ndparent, _
			Id, _
			delete, _
			DestinationDirectory, _
			DestinationLongName, _
			DestinationName, _
			DestinationProperty, _
			FileId, _
			SourceDirectory, _
			SourceName, _
			SourceProperty)
	If Id = "" Then Exit Function


	Dim nd


	Set nd = NewChild(ndparent, "CopyFile")
	nd.setAttribute "Id", Id
	If delete <> "" Then nd.setAttribute "Delete", delete
	If DestinationDirectory <> "" Then nd.setAttribute "DestinationDirectory", DestinationDirectory
	If DestinationLongName <> "" Then nd.setAttribute "DestinationLongName", DestinationLongName
	If DestinationName <> "" Then nd.setAttribute "DestinationName", DestinationName
	If DestinationProperty <> "" Then nd.setAttribute "DestinationProperty", DestinationProperty
	If FileId <> "" Then nd.setAttribute "FileId", FileId
	If SourceDirectory <> "" Then nd.setAttribute "SourceDirectory", SourceDirectory
	If SourceName <> "" Then nd.setAttribute "SourceName", SourceName
	If SourceProperty <> "" Then nd.setAttribute "SourceProperty", SourceProperty


	Set processCopyFileEx = nd
End Function


Function processUninstallXMLFile(ndparent, id, Action, File, ElementPath, Name,Value)
	dim nd


	set nd = NewChild(ndparent, "XmlFile")
	nd.setAttribute "Id", id
	nd.setAttribute "Action", Action
	nd.setAttribute "File", File
	nd.setAttribute "ElementPath", ElementPath
	nd.setAttribute "Name", Name
	nd.setAttribute "Value", Value
	
	Set processUninstallXMLFile = nd
End Function


Function processFolder(folder, byval depth, ndparent, ndFeature,catatype, directoryIDKey)
	dim	f, folderlist, fnd
	dim filelist, file
    dim fremove 
    dim fregistry
    dim fname       
	dim	ndNewFeature
	dim ndNewDirectory
	dim ndComponent
	dim ndFile
	dim guid
	dim guidreplaced
	dim selfreg
	dim nd
	dim assembly
	dim bksrcdir
	dim ndParentNode
	dim cp1
	dim cp2
	dim doaction
	dim directoryID
	dim aliasname
	dim Permanent
    dim gacreg
	Set ndNewFeature = ndFeature
	Set f = fso.GetFolder(folder)
	Set folderlist = f.SubFolders


	For each fnd in folderlist
		Select case depth
		Case 0			' 第一级分类目录 如:应该服务器,客户端,数据服务器
			Set ndNewFeature = processFeature(fnd.Name)
			Set ndNewDirectory = ndparent
			
			' 如果根目下有License.rtf文件的时候,自动增加到License属性值
			If licencefile = "" Then
				licencefile = f.Path & "\license.rtf" 
			End If
			' 如果没有指定环境检测配置文件,则默认取根目录下的envCheck.xml文件
			If envCheckfile= "" Then
				envCheckfile= f.Path & "\envCheck.xml" 
			End If
			If serviceControlFile= "" Then
			   serviceControlFile= f.Path & "\ServiceControl.xml" 
			End If
		Case 1			' 第二级分类表示改目录分别是什么类型的文件,如COM,COM+,NET,RUN
			Set ndNewDirectory = ndparent
			catatype = GetDirecotryCatalogType(fnd.Name)
		Case Else
			If Ucase(fnd.Name) = "TARGET" and depth=2 Then
				Set ndNewDirectory = ndrootDirectory
			Else
				Set ndNewDirectory = ndparent.SelectSingleNode("Directory[@Name='" & fnd.ShortName & "']")


				If ndNewDirectory is NOTHING Then
					If depth = 2 and IsSystemFolderProperties(fnd.Name)  Then
						directoryID = fnd.Name
					Else
						directoryID = "_" & GetGuididentifier(CreateGUID)
					End If
					If fnd.ShortName = fnd.Name Then
						Set ndNewDirectory = processDirectory(ndparent, directoryID, fnd.ShortName, "")
					Else
						Set ndNewDirectory = processDirectory(ndparent, directoryID, fnd.ShortName, fnd.Name)
					End If
				Else
					directoryID = ndNewDirectory.getAttribute("Id")
				End If
			End If
		End Select 
		processFolder fnd, depth + 1, ndNewDirectory, ndNewFeature, catatype, directoryID
	Next


	Select case depth
	Case 0
	Case 1
	Case Else
		SELECT CASE catatype
		CASE CATA_COM,CATA_NOTUNINSTALLCOM
			selfreg = "1"
			If catatype = CATA_NOTUNINSTALLCOM Then 
				Permanent = "yes"
			End If
		CASE CATA_NET,CATA_NETBOTH
			gacreg = "1"
			'assembly = ".net"
		case CATA_NOTUNINSTALL,CATA_RUN,CATA_RUNBEFORE,CATA_RUNWITHARGSP,CATA_RUNAFTERREMOVE,CATA_RUNUNINSTALL
			Permanent = "yes"
		END SELECT


		Set filelist = f.Files
		For each file in filelist
			If UCASE(f.Name) = "TARGET" Then
				bksrcdir = "TARGETDIR"
			Else
				bksrcdir = directoryIDKey
			End If


			doaction = "CP"
			If selfreg = "1" then
				doaction = "RG"
			elseif gacreg = "1" then				
				doaction = "GC"			
			End If
             


			if lcase(file.Name) = "$$$$$webvirtualdir$$$" then
				' 虚拟WEB目录
				Set fvir = fso.OpenTextFile(file.Path, 1)
				aliasname = fvir.ReadLine
				guid = CreateGUID
				guidreplaced = GetGuididentifier(guid)
				Set ndComponent = processComponent(ndparent, "cpt." + guidreplaced, guid)
				processComponentRef ndFeature, "cpt." + guidreplaced
				ProcessWebvirtual ndComponent, "virtauldir" & guidreplaced, aliasname, bksrcdir, "", "","默认网站"				
			Elseif lcase(file.Name) = "$$$$$removefile$$$" then
				' 需要删除的文件集合
				Set fremove = fso.OpenTextFile(file.Path, ForReading)                                
				Do  While Not  fremove.AtEndOfStream
				    guid = CreateGUID
				    guidreplaced = GetGuididentifier(guid)
				    Set ndComponent = processComponent(ndparent, "cpt." + guidreplaced, guid)
				    processComponentRef ndFeature, "cpt." + guidreplaced
				    fname = fremove.ReadLine
                    processRemoveFile ndComponent, _
								"file." + guidreplaced, _
								 fname , _
								 fname, _
                                "install"                                                     
      			             
   				Loop
        		fRemove.Close	
        	Elseif lcase(file.Name) = "$$$$$addregistry$$$" then
				' 注册键值集合	
				dim faddreg			
				Set fregistry = fso.OpenTextFile(file.Path, ForReading) 				                             
				Do  While Not  fregistry.AtEndOfStream
				    faddreg = fregistry.ReadLine
				    Call RegisterCustomInfo("ADD",faddreg)
   				Loop
        		fregistry.Close	
		Elseif lcase(file.Name) = "$$$$$removeregistry$$$" then
				' 注册键值集合	,由配置文件决定对键值的操作
				dim freg			
				Set fregistry = fso.OpenTextFile(file.Path, ForReading) 				                             
				Do  While Not  fregistry.AtEndOfStream
				    freg = fregistry.ReadLine
				    Call RegisterCustomInfo("REMOVE",freg)
   				Loop
        			fregistry.Close				
			Else
				guid = CreateGUID
				guidreplaced = GetGuididentifier(guid)
				guidreplaced=guidreplaced& "." & CreateFileDateStr(file.Path)
				
				if file.Name= "WINGDNG2.TTF" or file.Name = "pdf417.ttf" or file.Name = "BCSPDF417.ttf" or file.Name = "Resources.Config.xml" or file.Name = "uffilemanager.mdb" Then
				    Set ndComponent = processComponentEx(ndparent, "cpt." + guidreplaced, guid,"yes")
			    Elseif Permanent="yes" then
				    Set ndComponent = processComponentEx(ndparent, "cpt." + guidreplaced, guid,"yes") 
				else
				    Set ndComponent = processComponent(ndparent, "cpt." + guidreplaced, guid)
				end if
				
				'AddConditionNode ndComponent, _
		        '                "file." +guidreplaced &" = ""1""", _
		        '                ""
                		if RestoreDisabled=False then
					processCopyFileEx ndComponent, _
								"toback." & guidreplaced, _
								"yes", _
								"currbak", _
								file.Name & "#file." & guid & "." & CreateFileDateStr(file.Path) & "#" & doaction, _
								file.ShortName, _
								"", _
								"", _
								bksrcdir, _
								file.Name, _
								""
                                end if


				filecount = filecount + 1


				processComponentRef ndFeature, "cpt." + guidreplaced
				Set ndFile = processFile(ndComponent, _
								"file." + guidreplaced, _
								file.ShortName, _
								file.Name, _
								file.Path, _
								"yes", _
								"yes", _
								"1", _
								selfreg, _
								assembly)
				if justuap = True then
					If lcase(file.Name) = "ufida.u8.uap.services.billservice.dll" and instr(1,file.path,"SOURCEDIR\APP")>0 then
						'ProcessCustomAction ndProduct, "ccaReg" + guidreplaced, "ignore", "regsvcs", " /fc [#file." + guidreplaced + "] "	
						'If Not dict.Exists("ccaReg" + guidreplaced) Then
						'	dict.Add "ccaReg" + guidreplaced, "ccaReg" + guidreplaced
						'End If
						AppendCustomProperty "regsvcs","file." + guidreplaced
					End If
				end if


				SELECT CASE catatype
				CASE CATA_RUN
					if cataSetupType=CATA_DB then
							'ProcessCustomAction ndProduct, "cca" + guidreplaced, "asyncWait", "DBEnginSys", " -q -n:"	+spid
    							
							'ProcessCustomActionDll ndProduct, "cca" + guidreplaced, "check", "ufutils","ExcuteDBEnginSys"
							'ProcessCustomActionError ndProduct ,"errDBEnginSys","由于数据库脚本执行时出错,当前补丁安装失败!请卸载当前补丁并联系补丁开发人员."
							'ProcessPropertyEx ndProduct,"DBEnginSysPath","[#file." + guidreplaced + "]"
							'If Not dict.Exists("cca" + guidreplaced) Then
							'	dict.Add "cca" + guidreplaced, "cca" + guidreplaced
							'End if
							'If Not dict.Exists("errDBEnginSys") Then
							'	dict.Add "errDBEnginSys", "errDBEnginSys"
							'End if
							AppendCustomProperty "DBRUN","[#file." + guidreplaced + "]"
					else
							ProcessCustomAction ndProduct, "cca" + guidreplaced, "asyncWait", "viewer", "[#file." + guidreplaced + "]"	
							If Not dict.Exists("cca" + guidreplaced) Then
								'dict.Add "cca" + guidreplaced, "cca" + guidreplaced
                                 if cataSetupType=CATA_APP then
								   dict.Add "cca" + guidreplaced, "cca" + guidreplaced + "#FAPPC"
                                 else
                                   dict.Add "cca" + guidreplaced, "cca" + guidreplaced								
								 end if
							End if
					end if	
                CASE CATA_RUNBEFORE
                     ProcessCustomAction ndProduct, "CACustomAction_RunBefore", "asyncWait", "viewer", "[#file." + guidreplaced + "]"
		             If Not dictbefore.Exists("CACustomAction_RunBefore") Then
	                     dictbefore.Add "CACustomAction_RunBefore", "CACustomAction_RunBefore"
	                 End if					 
                CASE CATA_RUNWITHARGSP
                     AppendCustomProperty "SQLITERUN","[#file." + guidreplaced + "]"	
                CASE CATA_RUNAFTERREMOVE
                     AppendCustomProperty "AFTERRUN","[#file." + guidreplaced + "]"		
				CASE CATA_RUNUNINSTALL
				     ProcessCustomAction ndProduct, "CACustomPropertyAction6", "asyncWait", "viewer", "[#file." + guidreplaced + "]"	
					 If Not dict.Exists("CACustomPropertyAction6") Then
								'dict.Add "cca" + guidreplaced, "cca" + guidreplaced
                                 if cataSetupType=CATA_APP then
								   dict.Add "CACustomPropertyAction6" , "CACustomPropertyAction6"  + "#FAPPC"
                                 else
                                   dict.Add "CACustomPropertyAction6" , "CACustomPropertyAction6" 								
								 end if
					 End if


				CASE CATA_NET
					'ProcessCustomAction ndProduct, "ccagacutil" + guidreplaced, "ignore", "gacutil", " -i [#file." + guidreplaced + "] -f"
					'If Not dict.Exists("ccagacutil" + guidreplaced) Then
					'	dict.Add "ccagacutil" + guidreplaced, "ccagacutil" + guidreplaced
					'End if
					AppendCustomProperty "gacutil","file." + guidreplaced
				CASE CATA_NETBOTH
				    'ProcessCustomAction ndProduct, "ccagacutil" + guidreplaced, "ignore", "gacutil", "-i [#file." + guidreplaced + "] -f"
					'If Not dict.Exists("ccagacutil" + guidreplaced) Then
					'	dict.Add "ccagacutil" + guidreplaced, "ccagacutil" + guidreplaced
					'End if
					'ProcessCustomAction ndProduct, "ccaregasm" + guidreplaced, "ignore", "RegAsm", "[#file." + guidreplaced + "] /tlb /codebase /silent"
					'If Not dict.Exists("ccaregasm" + guidreplaced) Then
					'	dict.Add "ccaregasm" + guidreplaced, "ccaregasm" + guidreplaced
					'End if
					AppendCustomProperty "gacutil","file." + guidreplaced
					AppendCustomProperty "regasm","file." + guidreplaced					
				CASE CATA_NETREGASM
					'ProcessCustomAction ndProduct, "ccaregasm" + guidreplaced, "ignore", "RegAsm", "[#file." + guidreplaced + "] /tlb /codebase /silent"
					'If Not dict.Exists("ccaregasm" + guidreplaced) Then
					'	dict.Add "ccaregasm" + guidreplaced, "ccaregasm" + guidreplaced
					'End if
					AppendCustomProperty "regasm","file." + guidreplaced
				CASE CATA_NETREGASM40
					'ProcessCustomAction ndProduct, "ccaregasm" + guidreplaced, "ignore", "RegAsm40", "[#file." + guidreplaced + "] /tlb /codebase /silent"
					'If Not dict.Exists("ccaregasm" + guidreplaced) Then
					'	dict.Add "ccaregasm" + guidreplaced, "ccaregasm" + guidreplaced
					'End if
					AppendCustomProperty "regasm40","file." + guidreplaced					
				CASE CATA_COMPLUS
					'ProcessCustomAction ndProduct, "ccaregsvcs" + guidreplaced, "ignore", "RegSvcs", " /fc [#file." + guidreplaced + "] "
					'If Not dict.Exists("ccaregsvcs" + guidreplaced) Then
					'	dict.Add "ccaregsvcs" + guidreplaced, "ccaregsvcs" + guidreplaced
					'End if
					AppendCustomProperty "regsvcs","file." + guidreplaced
				CASE CATA_RUNONCE
						DIM ndcommFeaturerunonce
						DIM ndcomponentrunonce
						DIM guidrunonce
						DIM guidreplacedrunonce
						forceReboot = True
						guidrunonce = CreateGUID
						guidreplacedrunonce = GetGuididentifier(guidrunonce)
						Set ndcommFeaturerunonce = processFeature("App")
						Set ndcomponentrunonce   = processComponent(ndparent, "RUNONCE" + guidreplacedrunonce, guidrunonce)
						CALL processRegister(ndcomponentrunonce, "ONCE" & guidreplacedrunonce, "HKLM", REG_RUNONCE_KEYPATH, "string", "[$RUNONCE" & guidreplacedrunonce & "]\" & file.Name,file.ShortName)
						CALL processComponentRef(ndcommFeaturerunonce, "RUNONCE" + guidreplacedrunonce)									
				CASE CATA_REGSERVER					
						'ProcessCustomAction ndProduct, "cca" + guidreplaced, "asyncWait", "viewer", "[#file." + guidreplaced + "] /RegServer"	
						'If Not dict.Exists("cca" + guidreplaced) Then
						'	dict.Add "cca" + guidreplaced, "cca" + guidreplaced
						'End if	
                                                 AppendCustomProperty "regserver","file." + guidreplaced		
				CASE CATA_REGSVR32		
						
                                                 AppendCustomProperty "regsvr32","file." + guidreplaced
				END SELECT
			End if
		Next
	End Select
End Function


Function processBinary()
	dim nd
	dim filelist, f, folder
	dim path


	path = "Lib\Resource\"


	Set folder		= fso.GetFolder(path)
	Set filelist	= folder.Files


	For each f in filelist
		Set nd = NewChild(ndProduct, "Binary")
		nd.setAttribute "Id", fso.GetBaseName(f.Path)
		nd.setAttribute "src", path + f.Name
	Next
End Function


Function CreateGUID()
	dim o
	dim guid


	Set o = CreateObject("CAUTILS.Utils")
	guid = o.CreateGuid()
	CreateGUID = Replace(guid, "{", "")
	CreateGUID = Replace(CreateGUID, "}", "")
End Function


Function CreateFileDateStr(fileName)
	dim o	
	Set o = CreateObject("CAUTILS.Utils")
	CreateFileDateStr = o.GetFileDateStr(fileName)	
End Function


'''''''''''''''''''''''''''''''''''
' 
' 初始化
' 
''''''''''''''''''''''''''''''''''''
Function INIT()
	Set dict = CreateObject("Scripting.Dictionary")
	Set dictdeferca = CreateObject("Scripting.Dictionary")
	Set dictbefore = CreateObject("Scripting.Dictionary")
	set DOMObject = WScript.CreateObject("MSXML2.DOMDocument")


	IF NOT DOMObject is NOTHING THEN
		DOMObject.LoadXML "<?xml version='1.0' encoding='utf-8'?>" & _
						  "<Wix>" & _
						  "</Wix>"
	ELSE
		Wscript.Echo "Couldn't create DOMDocument Instance!"
	END IF
	
	Set fso = Wscript.CreateObject("Scripting.FileSystemObject")


	CALL InitMyCatalog
	Call InitSystemFolderProperties
	CALL InitDefaultValue
End Function


''''''''''''''''''''''''''''''''''''
' 
' 初始化系统默认值
' 
''''''''''''''''''''''''''''''''''''
Function InitDefaultValue()
	productName			= "安装程序"
	productManufacturer = "用友优普信息技术有限公司"
	productVersion		= "12.0.0.0"
	productLanguage		= "2052"
	codepage			= "936"


	packageKeywords		= "Installer, MSI, Database"
	packageDescription	= "补丁安装程序"
	packageComment		= "Comment"
	Compressed			= "yes"
	SummaryCodepage		= codepage
	installVersion		= "200"
	Platforms			= "Intel"


	productId			= CreateGUID
	productUpgradeCode	= CreateGUID
	packageID			= CreateGUID


	spid				= ""
	regVersionKey		= "V8.700"
	regKeyPath			= "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\SPINFO\" + spid
    regGuidPath         = "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\SmartGuid"
	disabledRollback	= True
	filecount			= 0
	forceReboot			= False
	RestoreDisabled             = False
	dependchecklist		= "" '"U8-V861-19-82987,U8-V861-19-82988"
	justuap				= False
End Function


Function InitMyCatalog()
	Redim arrMyCatalog(11)
	arrMyCatalog(0) = "COM"
	arrMyCatalog(1) = "COMPLUS"
	arrMyCatalog(2) = "NET"
	arrMyCatalog(3) = "OTHERS"
	arrMyCatalog(4) = "RUN"
	arrMyCatalog(5) = "SERVICE"
	arrMyCatalog(6) = "SPF"
    arrMyCatalog(7) = "RUNWITHARGSP"
	arrMyCatalog(8) = "RUNAFTERREMOVE"
	arrMyCatalog(9) = "RUNUNINSTALL"
    arrMyCatalog(10) = "RUNBEFORE"
End Function


''''''''''''''''''''''''''''''''''''
' 
' 初始化MSI系统能识别的系统目录关键值
' 
''''''''''''''''''''''''''''''''''''
Function InitSystemFolderProperties()
	Redim arrSystemFolders(27)
	arrSystemFolders(0) = "AdminToolsFolder"
	arrSystemFolders(1) = "AppDataFolder"
	arrSystemFolders(2) = "CommonAppDataFolder"
	arrSystemFolders(3) = "CommonFiles64Folder"
	arrSystemFolders(4) = "CommonFilesFolder"
	arrSystemFolders(5) = "DesktopFolder"
	arrSystemFolders(6) = "FavoritesFolder"
	arrSystemFolders(7) = "FontsFolder"
	arrSystemFolders(8) = "LocalAppDataFolder"
	arrSystemFolders(9) = "MyPicturesFolder"
	arrSystemFolders(10) = "PersonalFolder"
	arrSystemFolders(11) = "ProgramFiles64Folder"
	arrSystemFolders(12) = "ProgramFilesFolder"
	arrSystemFolders(13) = "ProgramMenuFolder"
	arrSystemFolders(14) = "SendToFolder"
	arrSystemFolders(15) = "StartMenuFolder"
	arrSystemFolders(16) = "StartupFolder"
	arrSystemFolders(17) = "System16Folder"
	arrSystemFolders(18) = "System64Folder"
	arrSystemFolders(19) = "SystemFolder"
	arrSystemFolders(20) = "TempFolder"
	arrSystemFolders(21) = "TemplateFolder"
	arrSystemFolders(22) = "WindowsFolder"
	arrSystemFolders(23) = "WindowsVolume"
End Function




''''''''''''''''''''''''''''''''''''
' 
' 判断指定的目录是否为已为识别的系统
' 目录
' 
''''''''''''''''''''''''''''''''''''
Function IsSystemFolderProperties(foldername)
	dim f


	For each f in arrSystemFolders
		If Ucase(f) = Ucase(foldername) Then
			IsSystemFolderProperties = TRUE
			Exit Function
		End If
	Next


	IsSystemFolderProperties = FALSE
End Function


''''''''''''''''''''''''''''''''''''
' 
' 处理产品结点
' 
''''''''''''''''''''''''''''''''''''
Function processProductNode()
	dim nd


	set nd = AppendChild(DomObject.documentElement, "Product")
	set ndProduct = nd


	nd.setAttribute "Id", productId
	nd.setAttribute "Name", productName
	nd.setAttribute "Manufacturer", productManufacturer
	nd.setAttribute "Language", productLanguage
	nd.setAttribute "Version", productVersion
	nd.setAttribute "UpgradeCode", productUpgradeCode
	nd.setAttribute "Codepage", codepage
End Function


''''''''''''''''''''''''''''''''''''
' 
' 处理Package结点
' 
''''''''''''''''''''''''''''''''''''
Function processPackageNode()
	dim nd
	set nd = AppendChild(ndProduct, "Package")


	nd.setAttribute "Id", packageID
	If packageKeywords<> "" Then nd.setAttribute "Keywords", packageKeywords
	If packageDescription<> "" Then nd.setAttribute "Description", packageDescription
	If productManufacturer<> "" Then nd.setAttribute "Manufacturer", productManufacturer
	If installVersion<> "" Then nd.setAttribute "InstallerVersion", installVersion
	If Platforms<> "" Then nd.setAttribute "Platforms", Platforms
	If productLanguage<> "" Then nd.setAttribute "Languages", productLanguage
	If Compressed<> "" Then nd.setAttribute "Compressed", Compressed
	If SummaryCodepage<> "" Then nd.setAttribute "SummaryCodepage", SummaryCodepage
End Function




''''''''''''''''''''''''''''''''''''
' 
' 处理UI结点
' 
''''''''''''''''''''''''''''''''''''
Function processUIs()
	set ndUI = AppendChild(ndProduct, "UI")


	processProperty ndUI, "ErrorDialog", "ErrorDlg"
	processProperty ndUI, "DefaultUIFont", "DlgFont8"


	processTextStyles ndUI
	processDialog ndUI


	processUITexts ndUI
	processActionTexts ndUI
	processErrors ndUI


	processInstallUISequence ndUI


	processDialogPropertys ndProduct
End Function






''''''''''''''''''''''''''''''''''''
' 
' 处理UI=>UIText结点
' 
''''''''''''''''''''''''''''''''''''
Function processUITexts(ndParent)
	dim dom
	dim ndroot
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load "Lib\UITextTable.xml"


	Set ndroot = dom.SelectSingleNode("//UITextInfo/UITexts[@Language='" + productLanguage + "']")
	For Each nd in ndroot.childNodes
		ndParent.appendChild nd
	Next
End Function




''''''''''''''''''''''''''''''''''''
' 
' 处理UI=>ActionText结点
' 
''''''''''''''''''''''''''''''''''''
Function processActionTexts(ndParent)
	dim dom
	dim ndroot
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load "Lib\ActionTextTable.xml"


	Set ndroot = dom.SelectSingleNode("//ActionTextInfo/ActionTexts[@Language='" + productLanguage + "']")
	For Each nd in ndroot.childNodes
		ndParent.appendChild nd
	Next
End Function




''''''''''''''''''''''''''''''''''''
' 
' 处理UI=>Error结点
' 
''''''''''''''''''''''''''''''''''''
Function processErrors(ndParent)
	dim dom
	dim ndroot
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load "Lib\ErrorTable.xml"


	Set ndroot = dom.SelectSingleNode("//ErrorsInfo/Errors[@Language='" + productLanguage + "']")
	For Each nd in ndroot.childNodes
		ndParent.appendChild nd
	Next
End Function


Function processDialogPropertys(ndParent)
	dim dom
	dim ndroot
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load "Lib\DialogTable.xml"


	Set ndroot = dom.SelectSingleNode("//DialogInfo/PropertyUIs[@Language='" + productLanguage + "']")
	For Each nd in ndroot.childNodes
		ndParent.appendChild nd
	Next		
End Function


Function processTextStyles(ndParent)
	processTextStyle ndParent, "DlgFont8", "SimSun", "8", "", "", "", "", "", "", ""
	processTextStyle ndParent, "SimSun__8", "SimSun", "8", "", "", "", "", "", "", ""
	processTextStyle ndParent, "TitleFontBold13", "SimSun", "11", "yes", "", "", "", "", "", ""
	processTextStyle ndParent, "DlgFontBold8", "SimSun", "8", "yes", "", "", "", "", "", ""
	processTextStyle ndParent, "VerdanaBold13", "Verdana", "11", "yes", "", "", "", "", "", ""
End Function


Function processTextStyle(ndParent,id,faceName, size, bold, italic, strike,underline,red,green,blue)
	dim nd


	set nd = NewChild(ndParent, "TextStyle")
	nd.setAttribute "Id", id
	nd.setAttribute "FaceName", faceName
	nd.setAttribute "Size", size
	If bold <> "" Then 	nd.setAttribute "Bold", bold
	If italic <> "" Then 	nd.setAttribute "Italic", italic
	If strike <> "" Then 	nd.setAttribute "Strike", strike
	If underline <> "" Then 	nd.setAttribute "Underline", underline
	If red <> "" Then 	nd.setAttribute "Red", red
	If green <> "" Then 	nd.setAttribute "Green", green
	If blue <> "" Then 	nd.setAttribute "Blue", blue
End Function


Function processDialog(ndParent)
	dim dom
	dim ndroot
	dim nd
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load "Lib\DialogTable.xml"


	Set ndroot = dom.SelectSingleNode("//DialogInfo/Dialogs[@Language='" + productLanguage + "']")
	For Each nd in ndroot.childNodes
		ndParent.appendChild nd
	Next	
End Function


''''''''''''''''''''''''''''''''''''
' 
' 增加一个条件结点
' 
''''''''''''''''''''''''''''''''''''
Function AddConditionNode( _
			ndparent, _
			condition, _
			message)
	Set AddConditionNode = AddConditionNodeEx(ndparent, condition, message, "", "")
End Function




''''''''''''''''''''''''''''''''''''
' 
' 增加一个条件结点
' 
''''''''''''''''''''''''''''''''''''
Function AddConditionNodeEx( _
			ndparent, _
			condition, _
			message, _
			action, _
			level)
	dim nd
	dim ndcdata


	If condition="" Then Exit Function
	Set nd = NewChild(ndparent, "Condition")
	If action <> "" Then nd.setAttribute "Action", action
	If level <> "" Then nd.setAttribute "Level", level
	If message <> "" Then nd.setAttribute "Message", message


	Set ndcdata = NewChildEx(nd, "Condition",4)
	ndcdata.text = condition


	set AddConditionNodeEx = nd
End Function




''''''''''''''''''''''''''''''''''''
' 
' 处理RootDirectory结点
' 
''''''''''''''''''''''''''''''''''''
Function ProcessRootDirectory()
	set ndrootDirectory = AppendChild(ndProduct, "Directory")


	ndrootDirectory.setAttribute "Id", "TARGETDIR"
	ndrootDirectory.setAttribute "Name", "SourceDir"
End Function




''''''''''''''''''''''''''''''''''''
' 
' 处理Media结点
' 
''''''''''''''''''''''''''''''''''''
Function processMedia()
	dim nd
	set nd = AppendChild(ndProduct, "Media")
	nd.setAttribute "Id", "1"
	nd.setAttribute "EmbedCab", "yes"
	nd.setAttribute "Cabinet", "product.cab"
End Function


''''''''''''''''''''''''''''''''''''
' 
' 为指点的XML结点增加一个子结点
' 
''''''''''''''''''''''''''''''''''''
Function AppendChildEx(ndParent, ndName, nodeType)
	Set AppendChildEx = AppendChildEx2(ndParent,ndName,nodeType, True)
End Function


Function AppendChildEx2(ndParent, ndName, nodeType, toreplace)
	dim nd
	If Not ndParent is NOTHING Then
		Set nd = NOTHING
		
		If toreplace Then
			Set nd = ndParent.SelectSingleNode(ndName)
		End If


		If nd Is NOTHING Then
			Set nd = DOMObject.createNode(nodeType, ndName, "")
			ndParent.appendChild nd
		End If
	End If


	Set AppendChildEx2 = nd
End Function


Function NewChild(ndParent, ndName)
	Set NewChild = NewChildEx(ndParent, ndName, 1)
End Function


Function NewChildEx(ndParent, ndName, nodeType)
	Set NewChildEx = AppendChildEx2(ndParent, ndName, nodeType, False)
End Function


Function AppendChild(ndParent, ndName)
	Set AppendChild = AppendChildEx(ndParent, ndName, 1)
End Function


Function ProcessPropertys()
	Call ProcessTargetProperty
	Call ProcessReInstallModeProperty
	If disabledRollback Then Call ProcessDisableRollback()
	Call ProcessFeatureCatalogProperty


	if dependchecklist<> "" then
		Call ProcessDependChecked
	end if
	Call ProcessEnvCheckFile
	call ProcessSPIDProperty
End Function


Function ProcessDisableRollback()
	dim nd
	Set nd = NewChild(ndProduct, "Property")


	nd.setAttribute "Id", "RollbackDisabled"
	nd.setAttribute "Value", "True"
End Function


Function ProcessReInstallModeProperty()
	dim nd
	Set nd = NewChild(ndProduct, "Property")


	nd.setAttribute "Id", "REINSTALLMODE"
	'nd.setAttribute "Value", "amus"
	nd.setAttribute "Value", REINSTALLMODE
End Function


Function ProcessSPIDProperty()
	dim nd
	Set nd = NewChild(ndProduct, "Property")


	nd.setAttribute "Id", "SPID"
	nd.setAttribute "Value", spid
End Function


Function ProcessPropertyEx(ndParent,id,value)
	dim nd
	Set nd = NewChild(ndProduct, "Property")


	nd.setAttribute "Id", id
	nd.setAttribute "Value", value
End Function




Function ProcessDependChecked()
	dim nd
	dim ndproperty
	dim ndChild
	dim i
	dim arr
	dim cur


	i = 0
	arr = split(dependchecklist, ",")
	for each cur in arr
		set ndproperty = NewChild(ndProduct, "Property")
		ndproperty.setAttribute "Id", "DEPEND" & i


		Set ndChild = NewChild(ndproperty, "RegistrySearch")
		ndChild.setAttribute "Id", "ppyDepend" & i
		ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\SPINFO\" & cur
		ndChild.setAttribute "Root", "HKLM"
		ndChild.setAttribute "Type", "raw"


		Call AddConditionNode(ndProduct, _
				"DEPEND" & i & " <>""""", _
				"[ProductName] 无法安装,因为相关补丁"& cur &"不存在")
		i = i+1
	next


End Function


Function ProcessEnvCheckFile()
	dim dom
	dim ndroot
	dim nd
	dim ndproperty
	dim ndChild
	dim i
	
	If envCheckfile= "" Then Exit Function
	If Not fso.FileExists(envCheckfile) Then Exit Function	
	i = 0
	
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load envCheckfile
	Set ndroot = dom.SelectSingleNode("//RegistryInfos")
	For Each nd in ndroot.childNodes
		
		set ndproperty = NewChild(ndProduct, "Property")
		ndproperty.setAttribute "Id", "ENVCHECK" & i


		Set ndChild = NewChild(ndproperty, "RegistrySearch")
		ndChild.setAttribute "Id", "ppyEnvCheck" & i




		ndChild.setAttribute "Key", nd.getAttribute("Key")


		if nd.getAttribute("Name")<>"" then ndChild.setAttribute "Name", nd.getAttribute("Name")
		ndChild.setAttribute "Root", nd.getAttribute("Root")
		ndChild.setAttribute "Type", nd.getAttribute("Type")


		Call AddConditionNode(ndProduct, _
				"ENVCHECK" & i & " =""" & nd.getAttribute("Value")&"""", _
				nd.getAttribute("Desc"))
		i = i+1
		
	Next	
		
	


End Function


Function ProcessTargetProperty()
	dim nd
	dim ndChild


	Set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "TARGETDIR"


	Set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "ppyTarget"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\CurrentInstPath"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"
End Function


Function ProcessRootDriveProperty()	
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", "CARootDrive"	
	nd.setAttribute "Property", "ROOTDRIVE"
	nd.setAttribute "Value", "[SystemFolder]"	
	
End Function
Function ProcessFeatureCatalogProperty()
	dim nd
	dim ndChild


	set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FAPPC"


	set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FAPPCppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\U8AppServer"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"
	
	set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FAPPEC"


	set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FAPPECppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\AppServer"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"


	set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FDBC"


	set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FDBCppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\DBServer"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"
        set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FDESC"


        set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FDESCppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\Client"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"
	
	set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FWEBC"


        set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FWEBCppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\WebServer"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"


	set nd = NewChild(ndProduct, "Property")
	nd.setAttribute "Id", "FLSC"


        set ndChild = NewChild(nd, "RegistrySearch")
	ndChild.setAttribute "Id", "FLSCppy"
	ndChild.setAttribute "Key", "SOFTWARE\Ufsoft\WF\" + regVersionKey + "\Install\Installed\LicenseServer"
	ndChild.setAttribute "Root", "HKLM"
	ndChild.setAttribute "Type", "raw"
End Function


Function ProcesslegalFile()
	dim buffer
	dim file
	dim nd
	dim ndText
	dim ncdata


	


	If licencefile = "" Then Exit Function
	If Not fso.FileExists(licencefile) Then Exit Function


	Set nd = DOMObject.SelectSingleNode("//Control[@Id='AgreementText']")
	If nd is NOTHING Then 
		Exit Function
	End IF




	Set file = fso.OpenTextFile(licencefile, ForReading)
	If file is NOTHING Then
		Exit Function
	End IF
	buffer = file.ReadAll()


	Set ndText = nd.SelectSingleNode("Text")
	If NOT ndText is NOTHING Then
		nd.removeChild(ndText)
	End If


	Set ndText = AppendChild(nd, "Text")


	Set ncdata = AppendChildEx(nd, "Text",4)
	ncdata.text = buffer
End Function


Function ProcessIniFile(ndParent, id, FileName, FileLongName, DirProperty,Section, Key,Value,Action)
	dim nd
	set nd = NewChild(ndParent, "IniFile")
	nd.setAttribute "Id", id
	nd.setAttribute "Action", Action
	if DirProperty <> "" Then nd.setAttribute "Directory", DirProperty
	nd.setAttribute "Key", Key
	nd.setAttribute "Section", Section
	nd.setAttribute "Value", Value
	nd.setAttribute "Name", FileName
	if FileLongName <> "" Then nd.setAttribute "LongName", FileLongName
	Set ProcessIniFile = nd
End Function


Function ProcessCustomAction(ndparent, id,  return, binaryKey, execommand)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", id
	nd.setAttribute "Return", return
	nd.setAttribute "BinaryKey", binaryKey
	nd.setAttribute "ExeCommand", execommand


	set ProcessCustomAction = nd
End Function


Function ProcessCustomActionExe(ndparent, id,  return,binaryKey, PropertyKey, execommand)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", id
	nd.setAttribute "Return", return
	nd.setAttribute "BinaryKey", binaryKey
	nd.setAttribute "Property", PropertyKey
	nd.setAttribute "ExeCommand", execommand


	set ProcessCustomActionExe = nd
End Function


Function ProcessCustomActionDll(ndparent, id,  return,binaryKey, dllentry,execute,impersonate)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", id
	nd.setAttribute "Return", return
	nd.setAttribute "BinaryKey", binaryKey	
	nd.setAttribute "DllEntry", dllentry
	nd.setAttribute "Execute", execute'"deferred"
	nd.setAttribute "Impersonate", impersonate'"no"
	set ProcessCustomActionDll = nd
End Function


Function ProcessCustomActionError(ndparent, id, error)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", id
	nd.setAttribute "Error", error	
	set ProcessCustomActionError = nd
End Function


Function ProcessUninstallCustomAction(ndparent)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", "CARollbackFiles"
	nd.setAttribute "Return", "asyncWait"
	nd.setAttribute "BinaryKey", "ufutils"
	nd.setAttribute "DllEntry", "RollbackBackupFiles"


	set ProcessUninstallCustomAction = nd
End Function


Function ProcessCustomActionProperty(ndparent, id,  PropertyKey, PropertyValue)
	dim nd
	Set nd = NewChild(ndProduct, "CustomAction")
	nd.setAttribute "Id", id
	nd.setAttribute "Property", PropertyKey
	nd.setAttribute "Value", PropertyValue	
	set ProcessCustomActionProperty = nd
End Function


'Function ProcessDependCheckedCustomAction(ndparent)
'	dim nd
'	Set nd = NewChild(ndProduct, "CustomAction")
'	nd.setAttribute "Id", "CADependChecked"
'	'nd.setAttribute "Return", "asyncWait"
'	nd.setAttribute "BinaryKey", "ufutils"
'	nd.setAttribute "DllEntry", "DependChecked"
'
'	set ProcessDependCheckedCustomAction = nd
'End Function


Function ProcessWebvirtual(ndParent, id, Alias, Directory, DirProperties,WebApplication,WebSite)
	dim nd
	dim ndaddr
	dim ndwebapplicate


	If nddefualtWebSite is Nothing Then
		set nddefualtWebSite = NewChild(ndProduct, "WebSite")


		nddefualtWebSite.setAttribute "Id", "DefaultWebSite"
		nddefualtWebSite.setAttribute "Description", "Defualt Web Site"
	


		set ndaddr = NewChild(nddefualtWebSite,"WebAddress")
		ndaddr.setAttribute "Id", "AllUnassigned"
		ndaddr.setAttribute "Port", "80"
	End If


	Set nd = NewChild(ndParent, "WebVirtualDir")


	nd.setAttribute "Id", id
	nd.setAttribute "Alias", Alias


	if Directory<>"" Then nd.setAttribute "Directory", Directory
	if DirProperties<>"" Then nd.setAttribute "DirProperties", DirProperties
	if WebApplication<>"" Then nd.setAttribute "WebApplication", WebApplication
	nd.setAttribute "WebSite", "DefaultWebSite"


	set ndwebapplicate = NewChild(nd,"WebApplication")
	ndwebapplicate.setAttribute "Id", "DefulatWebApplication"
	ndwebapplicate.setAttribute "Name", Alias


	Set ProcessWebvirtual = nd
End Function
'处理自定义行为的属性,用属性记录这些文件的关键字


Function AppendCustomProperty( key, id)    
	Select case Ucase(key)
	case "GACUTIL"
		if file_gacutil<>"" then
			file_gacutil=file_gacutil + "|" +"[#"+id+"]"
		else
			file_gacutil="[#"+id+"]"
		end if
	case "REGSVCS"
	if file_regsvcs<>"" then
			file_regsvcs=file_regsvcs + "|" +"[#"+id+"]"
		else			
			file_regsvcs="[#"+id+"]"
		end if	
	case "REGASM"
	if file_regasm<>"" then
			file_regasm=file_regasm + "|" +"[#"+id+"]"
		else
			file_regasm="[#"+id+"]"
		end if	
	case "REGASM40"
	if file_regasm40<>"" then
			file_regasm40=file_regasm40 + "|" +"[#"+id+"]"
		else
			file_regasm40="[#"+id+"]"
		end if			
	case "REGSERVER"
	if file_regserver<>"" then
			file_regserver=file_regserver+"|" +"[#"+id+"]"
		else
			file_regserver="[#"+id+"]"
		end if	
	case "REGSVR32"
	if file_regsvr32<>"" then
		file_regsvr32=file_regsvr32+"|" +"[#"+id+"]"
	else
		file_regsvr32="[#"+id+"]"
	end if	
	
    case "DBRUN"
	     DBEnginSysPath=id	


    case "SQLITERUN"
	     SQLITERUNSysPath=id	
		 
    case "AFTERRUN"
	     AFTERRUNSysPath=id			 
		 
	end select    
End Function
'给自定义的属性赋值
Function ProcessCustomProperty(ndParent)  
	Dim prefix	
	Dim limiter
	limiter="   "
	prefix="/REMOVE=[REMOVE]"+limiter+"/FILEPATH="
	
	if file_gacutil<>"" then
		'ProcessPropertyEx ndParent,"file_gacutil",file_gacutil
		ProcessCustomActionProperty ndParent,"CACustomPropertyAction_gacutil","CACustomAction_gacutil",prefix+file_gacutil+limiter+"/EXE=gacutil"
	end if
	if file_regsvcs<>"" then
		'ProcessPropertyEx ndParent,"file_regsvcs",file_regsvcs
		ProcessCustomActionProperty ndParent,"CACustomPropertyAction_regsvcs","CACustomAction_regsvcs",prefix+file_regsvcs+limiter+"/EXE=RegSvcs"
	end if
	if file_regasm<>"" then
		'ProcessPropertyEx ndParent,"file_regasm",file_regasm
		ProcessCustomActionProperty ndParent,"CACustomPropertyAction_regasm","CACustomAction_regasm",prefix+file_regasm+limiter+"/EXE=RegAsm"
	end If
    if file_regasm40<>"" then
		'ProcessPropertyEx ndParent,"file_regasm40",file_regasm40
		ProcessCustomActionProperty ndParent,"CACustomPropertyAction_regasm40","CACustomAction_regasm40",prefix+file_regasm40+limiter+"/EXE=RegAsm40"
	end If
	if file_regserver<>"" Or file_regsvr32<>"" Then	
		ProcessCustomActionProperty ndParent,"CACustomPropertyAction_regserver","CACustomPropertyAction2","/REMOVE=[REMOVE]"+limiter+"/REGSERVER="+file_regserver+limiter+"/REGSVR="+file_regsvr32
	End if
	'if file_regserver<>"" then
		'ProcessPropertyEx ndParent,"file_regserver",file_regserver
	'end if
	'if file_regsvr32<>"" then
		'ProcessPropertyEx ndParent,"file_regsvr32",file_regsvr32
	'end if
    if DBEnginSysPath<>"" then		
        ProcessPropertyEx ndParent,"DBEnginSysPath",DBEnginSysPath
	end if


    if SQLITERUNSysPath<>"" then		
        ProcessPropertyEx ndParent,"SQLITERUNSysPath",SQLITERUNSysPath
	end if
	
    if AFTERRUNSysPath<>"" then		
        ProcessPropertyEx ndParent,"AFTERRUNSysPath",AFTERRUNSysPath
	end if	


	
End Function
'给自定义的属性增加自定义的行为
Function ProcessCustomPropertyAction(ndParent)
	If file_gacutil<>"" Or file_regsvcs<>"" Or file_regasm<>"" Or file_regasm40<>"" Then
		Call ProcessCustomActionDll(ndParent,"CACustomAction_CreateBinaryFile","ignore","ufutils","CreateBinaryFile","immediate","yes")	
		If Not dictdeferca.Exists("CACustomAction_CreateBinaryFile") Then
	       dictdeferca.Add "CACustomAction_CreateBinaryFile", "CACustomAction_CreateBinaryFile"
	    End if
	End if
	if file_gacutil<>""  then
		Call ProcessCustomActionDll(ndParent,"CACustomAction_gacutil","ignore","ufutils","ExcuteApp","deferred","no")		
		If Not dictdeferca.Exists("CACustomAction_gacutil") Then
			dictdeferca.Add "CACustomPropertyAction_gacutil", "CACustomPropertyAction_gacutil"
			dictdeferca.Add "CACustomAction_gacutil", "CACustomAction_gacutil"
		End if
	end if	
	if  file_regsvcs<>""  then
		Call ProcessCustomActionDll(ndParent,"CACustomAction_regsvcs","ignore","ufutils","ExcuteApp","deferred","no")		
		If Not dictdeferca.Exists("CACustomAction_regsvcs") Then
			dictdeferca.Add "CACustomPropertyAction_regsvcs", "CACustomPropertyAction_regsvcs"
			dictdeferca.Add "CACustomAction_regsvcs", "CACustomAction_regsvcs"
		End if
	end if	
	if  file_regasm<>"" then
		Call ProcessCustomActionDll(ndParent,"CACustomAction_regasm","ignore","ufutils","ExcuteApp","deferred","no")		
		If Not dictdeferca.Exists("CACustomAction_regasm") Then
			dictdeferca.Add "CACustomPropertyAction_regasm", "CACustomPropertyAction_regasm"
			dictdeferca.Add "CACustomAction_regasm", "CACustomAction_regasm"
		End if
	end if	
	if  file_regasm40<>"" then
		Call ProcessCustomActionDll(ndParent,"CACustomAction_regasm40","ignore","ufutils","ExcuteApp","deferred","no")		
		If Not dictdeferca.Exists("CACustomAction_regasm40") Then
			dictdeferca.Add "CACustomPropertyAction_regasm40", "CACustomPropertyAction_regasm40"
			dictdeferca.Add "CACustomAction_regasm40", "CACustomAction_regasm40"
		End if
	end if	
    if file_regserver<>"" or file_regsvr32<>"" then
		Call ProcessCustomActionDll(ndParent,"CACustomPropertyAction2","ignore","ufutils","ExcuteRegServer","deferred","no")		
		If Not dictdeferca.Exists("CACustomPropertyAction2") Then
			dictdeferca.Add "CACustomPropertyAction_regserver", "CACustomPropertyAction_regserver"
			dictdeferca.Add "CACustomPropertyAction2", "CACustomPropertyAction2"
		End if
	end if	
    if DBEnginSysPath<>"" then	
           ProcessCustomActionDll ndParent, "CACustomPropertyAction3", "check", "ufutils","ExcuteDBEnginSys","immediate","yes"
	       ProcessCustomActionError ndParent ,"errDBEnginSys","由于数据库脚本执行时出错,当前补丁安装失败!请卸载当前补丁并联系补丁开发人员."
	    If Not dict.Exists("CACustomPropertyAction3") Then
	       dict.Add "CACustomPropertyAction3", "CACustomPropertyAction3"
	    End if
	    If Not dict.Exists("errDBEnginSys") Then
	       dict.Add "errDBEnginSys", "errDBEnginSys"
	    End if
	end if
    if SQLITERUNSysPath<>"" then	
           ProcessCustomActionDll ndParent, "CACustomPropertyAction4", "check", "ufutils","ExcuteSqlLiteSys","immediate","yes"
	       ProcessCustomActionError ndParent ,"errSqlLiteSys","补丁信息导入出错,请联系补丁开发人员."
	    If Not dict.Exists("CACustomPropertyAction4") Then
	       dict.Add "CACustomPropertyAction4", "CACustomPropertyAction4"
	    End if
	    If Not dict.Exists("errSqlLiteSys") Then
	       dict.Add "errSqlLiteSys", "errSqlLiteSys"
	    End if
	end if	
	
	if AFTERRUNSysPath<>"" then	
           ProcessCustomActionDll ndParent, "CACustomPropertyAction5", "check", "ufutils","UninstallExcuteEnginSys","immediate","yes"
	       ProcessCustomActionError ndParent ,"errExeSys","卸载补丁信息出错,请联系补丁开发人员."
	    If Not dict.Exists("CACustomPropertyAction5") Then
	       dict.Add "CACustomPropertyAction5", "CACustomPropertyAction5"
	    End if
	    If Not dict.Exists("errExeSys") Then
	       dict.Add "errExeSys", "errExeSys"
	    End if
	end if	
	
End Function
''''''''''''''''''''''''''''''''''''
' 
' 处理Upgrade结点
' 
''''''''''''''''''''''''''''''''''''
Function processUpgradeNode()
	dim nd
	dim ndUpgradeVersion
	set nd = AppendChild(ndProduct, "Upgrade")
	nd.setAttribute "Id", productUpgradeCode
	set ndUpgradeVersion=NewChild(nd ,"UpgradeVersion")
	ndUpgradeVersion.setAttribute "Property" ,"RELATEDPROPROPERTY"
End Function
Function ProcessServiceControlFile()
	dim dom
	dim ndroot
	dim nd
	dim ndproperty
	dim ndChild
	dim i
	
	dim ndcommFeature
	dim ndcomponent
	dim guid
	dim action
	dim guidreplaced
	Dim  arr 


	If serviceControlFile= "" Then Exit Function
	If Not fso.FileExists(serviceControlFile) Then Exit Function
	Set dom = WScript.CreateObject("MSXML2.DOMDocument")
	dom.Load serviceControlFile
	Set ndroot = dom.SelectSingleNode("//Services")
        Set ndcommFeature = processFeature("APP")
	For Each nd in ndroot.childNodes
	    guid = CreateGUID
	    guidreplaced = GetGuididentifier(guid)
	    Set ndcomponent   = processComponent(ndrootDirectory, "Srv" & guidreplaced, guid)
	    call processServiceStop(ndcomponent,"srv" & guidreplaced,nd.getAttribute("Name"),nd.getAttribute("Stop"),nd.getAttribute("Wait"))
            CALL processComponentRef(ndcommFeature, "Srv" & guidreplaced)	
	Next	


End Function
Function processServiceStop(ndparent, id, name, stopflag, wait)
	dim nd 
	Set nd = NewChild(ndparent, "ServiceControl")
	nd.setAttribute "Id", id
	nd.setAttribute "Name", name
	nd.setAttribute	"Stop", stopflag
	nd.setAttribute	"Wait", wait
	Set processServiceStop = nd
End Function


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值