Skip to content

Commit

Permalink
Add a task schedule when the msi is installed
Browse files Browse the repository at this point in the history
A windows task schdule is created which runs the syncer hourly.
  • Loading branch information
guenhter committed Jun 21, 2024
1 parent 15e7c6b commit f154089
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 639 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install WiX
run: dotnet tool install --global wix
- name: Create MSI
run: wix build .\package.wxs -o SimpleFolderSyncer.msi
run: wix build .\package.wxs -o SimpleFolderSyncer.msi -arch x64
- name: Upload WiX Installer
uses: actions/upload-artifact@v4
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/target
target/
.vscode/
.wix/

*.log
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ walkdir = "2.5.0"
windows-sys = { version = "0.52.0", features = [
"Win32_System_Threading",
"Win32_Storage_FileSystem",

"Wdk_Foundation",
"Wdk_Storage_FileSystem",
"Win32_Foundation",
"Win32_System_IO",
"Win32_System_Kernel",
] }
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ cargo wix


```ps1
# Building the MSI
wix build .\package.wxs -o my.msi -arch x64
# Install an MSI and create the log for the installation process
msiexec /i my.msi /l*v install.log
Expand Down
7 changes: 0 additions & 7 deletions build.bat

This file was deleted.

9 changes: 9 additions & 0 deletions install-schedule.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

set "BatchFilePath=%programfiles%\Simple Folder Syncer\simple-folder-syncer.exe"

set "TaskName=Simple Folder Syncer"
set "TaskDescription=Run my batch file daily"

:: https://learn.microsoft.com/de-de/windows/win32/taskschd/schtasks
schtasks /create /f /tn "%TaskName%" /tr "%BatchFilePath%" /sc hourly
40 changes: 27 additions & 13 deletions package.wxs
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Simple Folder Syncer" Manufacturer="Grill Günther" UpgradeCode="9e914e0d-014b-4a92-a147-755ad34dfc26" Version="0.1">
<MediaTemplate EmbedCab="yes" />

<StandardDirectory Id="ProgramFilesFolder">
<Directory Id="SyncerFolder" Name="Simple Folder Syncer" />
</StandardDirectory>

<Feature Id="Main">
<Component Directory="SyncerFolder">
<File Source="target\\release\\simple-folder-syncer.exe" />
</Component>
</Feature>
</Package>
<Package Name="Simple Folder Syncer" Manufacturer="Grill Günther" UpgradeCode="9e914e0d-014b-4a92-a147-755ad34dfc26" Version="0.1">
<Icon Id="icon.ico" SourceFile="resources\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Property Id="ARPNOMODIFY" Value="no" Secure="yes" />

<MediaTemplate EmbedCab="yes" />

<StandardDirectory Id="ProgramFiles64Folder">
<Directory Id="SyncerFolder" Name="Simple Folder Syncer" />
</StandardDirectory>

<Feature Id="Main">
<Component Directory="SyncerFolder" Guid="ef88aca5-ca0f-49b3-a95b-385d7c9a2965">
<File Source="target\\release\\simple-folder-syncer.exe" />
<File Id="InstallScheuduleCmd" Source="install-schedule.bat" />
<File Id="UninstallScheuduleCmd" Source="uninstall-schedule.bat" />
</Component>
</Feature>

<CustomAction Id='InstallSchedule' FileRef='InstallScheuduleCmd' ExeCommand='' Execute='immediate' Impersonate='no' Return='check' />
<CustomAction Id='UninstallSchedule' FileRef='UninstallScheuduleCmd' ExeCommand='' Execute='immediate' Impersonate='no' Return='check' />

<InstallExecuteSequence>
<Custom Action="InstallSchedule" After="InstallFinalize" Condition="NOT Installed"/>
<Custom Action="UninstallSchedule" Before="InstallFinalize" Condition='Installed AND ( REMOVE = "ALL" OR AI_INSTALL_MODE = "Remove" ) AND NOT UPGRADINGPRODUCTCODE'/>
</InstallExecuteSequence>
</Package>
</Wix>
Binary file added resources/icon.ico
Binary file not shown.
Loading

0 comments on commit f154089

Please sign in to comment.