pc-inventory/agent.wxs
2026-05-18 15:24:46 +02:00

59 lines
3.1 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:sched="http://schemas.microsoft.com/wix/SchedExtension">
<Product Id="*" Name="PC Inventory Agent" Language="1031" Version="1.0.0.0" Manufacturer="PC Inventory" UpgradeCode="7e3b8a1c-8b2d-4f1e-9c3a-5d6e7f8a9b0c">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="Eine neuere Version von [ProductName] ist bereits installiert." />
<MediaTemplate EmbedCab="yes" />
<Property Id="SERVERURL" Value="http://localhost:8080" />
<Feature Id="ProductFeature" Title="PC Inventory Agent" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ScheduledTaskComponent" />
</Feature>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="PCInventoryAgent" />
</Directory>
</Directory>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="AgentScript" Guid="a1b2c3d4-e5f6-4a5b-bc6d-7e8f9a0b1c2d">
<File Id="AgentPs1" Source="agent.ps1" KeyPath="yes" />
</Component>
</ComponentGroup>
<DirectoryRef Id="TARGETDIR">
<Component Id="ScheduledTaskComponent" Guid="f1e2d3c4-b5a6-4987-8765-43210fedcba9">
<util:ServiceConfig
ServiceName="PCInventoryAgentTask"
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="runCommand" />
<!-- We use a custom action to create the scheduled task because WiX 3 doesn't have a native element for Task Scheduler 2.0 -->
<CustomAction Id="CreateScheduledTask"
Directory="INSTALLFOLDER"
ExeCommand='schtasks /Create /TN "PCInventoryAgent" /SC HOURLY /ST 00:00 /TR "powershell.exe -ExecutionPolicy Bypass -File \"[INSTALLFOLDER]agent.ps1\" -ServerUrl \"[SERVERURL]\"" /RU "System" /F'
Return="check"
Execute="deferred"
Impersonate="no" />
<CustomAction Id="RemoveScheduledTask"
Directory="INSTALLFOLDER"
ExeCommand='schtasks /Delete /TN "PCInventoryAgent" /F'
Return="ignore"
Execute="deferred"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask" Before="InstallFinalize">NOT Removed</Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">Removed</Custom>
</InstallExecuteSequence>
</Component>
</DirectoryRef>
</Product>
</Wix>