<?xml version="1.0" encoding="UTF-8"?>
<SapSetup Context="Init">
	<Product Guid="{61871EC9-28EC-4cff-B239-FD7AA604A2B9}" Name="SAP WUS Shared" CmdLine="WUS_Shared" WkstaDb="SapWUSWksta.xml" ProdVersion="157" Visible="FALSE"/>
	<Component Guid="{5C4D15BE-7199-4927-9E63-7A0E0CA207D4}" Name="$SAPWUS ARP" Version="2" Min_Compliant_Version="1">
		<Action Type="Registry" Dst="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SAP_WUS">
			<RegValue Name="DisplayName">SAPSetup Automatic Workstation Update Service</RegValue>
			<RegValue Name="DisplayIcon">&quot;%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe&quot;,0</RegValue>
			<RegValue Name="Publisher">SAP AG</RegValue>
			<RegValue Name="URLUpdateInfo">http://service.sap.com</RegValue>
			<RegValue Name="UninstallString">&quot;%SAPSetupDir%\setup\NwSapSetup.exe&quot; /product:&quot;SAPWUS&quot; /uninstall</RegValue>
		</Action>
	</Component>
	<Component Guid="{25596A32-5EBF-4fa7-8B3E-1871FAAB6353}" Name="$SAPWUS Shared Keys" Version="1" Min_Compliant_Version="1">
		<Action Type="Registry" Dst="HKLM\SOFTWARE\SAP\SAP Shared\SAP_WUS">
			<RegValue>SAPSetup Automatic Workstation Update Service</RegValue>
			<RegValue Name="SAPSourceDir">%SAPSrcDir%</RegValue>
			<RegValue Name="SAPDestDir">%SapWUSDestDir%</RegValue>
		</Action>
	</Component>
	<Component Guid="{41D37BB1-B482-41bc-A1A4-B3662A55A021}" Name="$SAPWUS Configurations" Version="1" Min_Compliant_Version="1" Size="1000">
		<Action Dst="%SAPSetupDir%\setup\Updater" Type="File">
			<Src>%SapSrcDir%\Setup\Updater\WkstaUpdater.cfg</Src>
		</Action>
	</Component>
	<Component Guid="{73BD1C1C-878A-49fa-AC4D-DB11688F2D0B}" Name="$SAPWUS Files" Version="158" Min_Compliant_Version="1" Size="2106" SysSize="476">
		<Requires Guid="{41D37BB1-B482-41bc-A1A4-B3662A55A021}" Name="$SAPWUS Configurations"/>
		<Action RunAt="Install" Type="Script">
			<Src>
				<![CDATA[
					Dim bElevated
					bElevated = vbFalse
					bElevated = NwEngine.DE.CommandLineArguments.IsArgumentSupplied("elevated")
					NwEngine.Variables.InsertVariable "Param_Elevated", "FALSE"
					NwEngine.Variables.Persistent("Param_Elevated") = vbFalse
					If bElevated Then
						NwEngine.Context.log.Write "Script-Action: /Elevated"
						NWEngine.Variables.AppendDefaultValue "Param_Elevated", "TRUE"
					Else
						NwEngine.Context.log.Write "Script-Action: Not running in /Elevated mode. NwSapSetupUserNotificationTool.exe (if existing) should close first."
					End If
					NwEngine.Variables.InsertVariable "Exists_NotificationTool", "FALSE"
					NwEngine.Variables.Persistent("Exists_NotificationTool") = vbFalse
					If NwEngine.Shell.FileExist("%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe") Then
						NWEngine.Variables.AppendDefaultValue "Exists_NotificationTool", "TRUE"
					End If
				]]>
			</Src>
		</Action>
		<!-- Stop "NwSapSetupUserNotificationTool.exe" before patching it! -->
		<Action Type="Execute" RunAt="Install" Condition="(%Param_Elevated%=FALSE)&amp;(%Exists_NotificationTool%=TRUE)">
			<Src TimeOut="60000" SuppressWindow="TRUE" DisplayText="Closing User Notification Tool" Parameters=" -ShutDown">%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe</Src>
		</Action>
		<!-- Should NwSapSetupUserNotificationTool.exe not respond to the exit command as supplied above, we should forcibly bring it down that it can be replaced. -->
		<Action RunAt="Install" Type="Script" Condition="%Param_Elevated%=FALSE">
			<Src>
				<![CDATA[
				NwEngine.Shell.TerminateProcessInstances("NwSapSetupUserNotificationTool.exe")
				]]>
			</Src>
		</Action>
		<Action Type="NtService" Dst="%SAPSetupDir%\setup\Updater" Description="SAPSetup Automatic Workstation Update Service" DisplayName="SAPSetup Automatic Workstation Update Service" ExeName="%SAPSetupDir%\setup\Updater\NwSapAutoWorkstationUpdateService.exe" ServiceName="NWSAPAutoWorkstationUpdateSvc" StartOnServer="FALSE">
			<Src>%SapSrcDir%\Setup\Updater\NwSapAutoWorkstationUpdateService.exe</Src>
			<Src>%SapSrcDir%\Setup\Updater\NwSapFeiLg.dll</Src>
		</Action>
		<!-- "NwSapSetupUserNotificationTool.exe" also uses "NwSapFeiLg.dll" -->
		<Action Dst="%SAPSetupDir%\setup\Updater" Type="File">
			<Src>%SapSrcDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe</Src>
		</Action>
		<!-- Kill "NwSapSetupUserNotificationTool.exe" before removing it at uninstall time, if the stop command below timed out! (Reverse order of Actions during uninstall!) -->
		<Action RunAt="Uninstall" Type="Script" Condition="%Param_Elevated%=FALSE">
			<Src>
				<![CDATA[
				NwEngine.Shell.TerminateProcessInstances("NwSapSetupUserNotificationTool.exe")
				]]>
			</Src>
		</Action>
		<!-- Stop "NwSapSetupUserNotificationTool.exe" before uninstalling it! (Reverse order of Actions during uninstall!) -->
		<Action Type="Execute" RunAt="Uninstall" Condition="%Param_Elevated%=FALSE">
			<Src TimeOut="10000" SuppressWindow="TRUE" DisplayText="Closing User Notification Tool" Parameters=" -ShutDown">%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe</Src>
		</Action>
		<!-- Start "NwSapSetupUserNotificationTool.exe" after installing it! -->
		<Action Type="Execute" RunAt="Install">
			<Src NoWaitOnExecute="TRUE" TimeOut="0" SuppressWindow="TRUE" DisplayText="Starting User Notification Tool">%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe</Src>
		</Action>
		<!-- Add "NwSapSetupUserNotificationTool.exe" to the Run Key! -->
		<Action Type="Registry" Dst="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run">
			<RegValue Name="SAP_WUS_UNT">&quot;%SAPSetupDir%\setup\Updater\NwSapSetupUserNotificationTool.exe&quot;</RegValue>
		</Action>
		<Action RunAt="UnInstall" Type="Script">
			<Src>
				<![CDATA[
					Dim bElevated
					bElevated = vbFalse
					bElevated = NwEngine.DE.CommandLineArguments.IsArgumentSupplied("elevated")
					NwEngine.Variables.InsertVariable "Param_Elevated", "FALSE"
					NwEngine.Variables.Persistent("Param_Elevated") = vbFalse
					If bElevated Then
						NwEngine.Context.log.Write "Script-Action: /Elevated"
						NWEngine.Variables.AppendDefaultValue "Param_Elevated", "TRUE"
					Else
						NwEngine.Context.log.Write "Script-Action: Not running in /Elevated mode. NwSapSetupUserNotificationTool.exe (if existing) should close first."
					End If
					NwEngine.Variables.InsertVariable "Exists_NotificationTool", "FALSE"
					NwEngine.Variables.Persistent("Exists_NotificationTool") = vbFalse
					If NwEngine.Shell.FileExist("%SapSetupDir%\Setup\Updater\NwSapSetupUserNotificationTool.exe") Then
						NWEngine.Variables.AppendDefaultValue "Exists_NotificationTool", "TRUE"
					End If
				]]>
			</Src>
		</Action>
	</Component>
</SapSetup>
