Commit deb7f5e3 authored by Yuanle Song's avatar Yuanle Song

install scheduled tasks when installing.

parent e417cae4
......@@ -6,7 +6,7 @@
<?xml version="1.0"?>
<Wix xmlns="">
<Product Id="*" UpgradeCode="3030B91E-5E3E-4151-9A69-B53B72690430" Version="$(var.Version)" Language="1033" Name="mbackup" Manufacturer="Yuanle Song">
<Package InstallerVersion="300" Compressed="yes"/>
<Package InstallScope="perMachine" InstallerVersion="300" Compressed="yes"/>
<Media Id="1" Cabinet="" EmbedCab="yes" />
<MajorUpgrade AllowDowngrades="yes"/>
......@@ -50,7 +50,7 @@
Description="Backup your computer using rsync"
<RemoveFolder Id="DesktopShortcut" On="uninstall"/>
<RemoveFolder Id="MbackupDesktopShortcut" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\mbackup\desktopshortcuts" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
......@@ -77,11 +77,43 @@
Description="mbackup local-exclude.txt file"
<RemoveFolder Id="MBACKUP_START_MENU_DIR" On="uninstall"/>
<RemoveFolder Id="mbackup_start_menu_dir" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\mbackup\startmenushortcuts" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<Custom Action="CreateScheduledTaskLogon" Before='InstallFinalize'>NOT Installed</Custom>
<Custom Action="RemoveScheduledTaskLogon" Before="RemoveFiles">Installed</Custom>
<Custom Action="CreateScheduledTaskInterval" Before='InstallFinalize'>NOT Installed</Custom>
<Custom Action="RemoveScheduledTaskInterval" Before="RemoveFiles">Installed</Custom>
<CustomAction Id="CreateScheduledTaskLogon"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU SYSTEM /RP /NP /SC ONLOGON /TN &quot;mbackup-logon&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackup.exe&quot; /DELAY 0015:00" />
<CustomAction Id="RemoveScheduledTaskLogon"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Delete /TN &quot;mbackup-logon&quot; /F" />
<CustomAction Id="CreateScheduledTaskInterval"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Create /RU SYSTEM /RP /NP /SC DAILY /TN &quot;mbackup-interval&quot; /TR &quot;[MBACKUP_PROGRAM_FILES]publish\mbackup.exe&quot; /ST 09:00 /DU 17:00 /RI 120 /K" />
<CustomAction Id="RemoveScheduledTaskInterval"
ExeCommand="&quot;[SystemFolder]SCHTASKS.EXE&quot; /Delete /TN &quot;mbackup-interval&quot; /F" />
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentGroupRef Id="MbackupHeatGenerated" />
<ComponentGroupRef Id="RsyncHeatGenerated" />
......@@ -91,6 +91,8 @@ dotnet run -- -i
Then you can follow the how-tos.
How To Guides
How To: Implement a Major Upgrade In Your Installer
......@@ -105,6 +107,9 @@ dotnet run -- -i
CustomAction Element
** 2019-11-13 install dir layout.
C:\Program Files\mbackup\rsync-w64\usr\bin\rsync.exe
C:\Program Files\mbackup\rsync-w64\usr\bin\ssh.exe
......@@ -221,6 +226,9 @@ vscode should at least always indent using space for F#.
* current :entry:
** 2019-11-16 how to sign my msi executable?
so it doesn't show publisher unknown.
** 2019-11-12 make code work in a specific dir. then create an installer.
- bundle dotnet core 3 with installer.
- DONE install binary files to %programfiles%
......@@ -229,9 +237,9 @@ vscode should at least always indent using space for F#.
SCHTASKS /Create /?
# run mbackup 15m after user logon.
SCHTASKS /Create /NP /SC ONLOGON /TN mbackup-logon /TR "\"<path\to\mbackup.exe>\" \"args\"" /DELAY 15:00
SCHTASKS /Create /NP /SC ONLOGON /TN mbackup-logon /TR "\"<path\to\mbackup.exe>\" \"args\"" /DELAY 0015:00
# run mbackup at 10am and 4pm.
SCHTASKS /Create /NP /SC DAILY /TN mbackup-morning /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 10:00 /ET 13:00 /K
SCHTASKS /Create /NP /SC DAILY /TN mbackup-morning /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 10:00 /ET 14:00 /K
SCHTASKS /Create /NP /SC DAILY /TN mbackup-afternoon /TR "\"<path\to\mbackup.exe>\" \"args\"" /ST 16:00 /ET 19:00 /K
# debug purpose, one time only
......@@ -304,6 +312,66 @@ vscode should at least always indent using space for F#.
logary/ at master · logary/logary · GitHub
this one is not free software.
- 2019-11-16 create scheduled task fail when installing.
how to check the output of the command?
msiexec /l*v log.txt /i mbackup-
only log error
msiexec /le loge.txt /i mbackup-
it's mbackup.exe path problem.
[INSTALLFOLDER] expands to empty string.
- after this change, command runs fine in admin cmd.exe window.
but when run in installer, still fail.
- &quot;[SystemFolder]SCHTASKS.EXE&quot;
same error. not escaping issue.
- error 1722 from simplest of .exe custom actions - Community
notepad.exe works in my case.
when I exit notepad.exe, installer exit successfully.
does it run as admin user? check.
it's run as system user. not administrator or current user.
it can't access desktop/documents etc.
maybe that's the reason?
» Using Windows Installer (WIX) to schedule a task as the system user RainbowInWater
SCHTASKS.EXE /Create /RU SYSTEM /RP /NP /SC ONLOGON /TN mbackup-logon /TR "C:\Program Files\mbackup\publish\mbackup.exe" /DELAY 0015:00
- try add /RU SYSTEM /RP
it works.
TODO task will run as SYSTEM user though.
how would home dir expand in SYSTEM user?
I'd like task to run as currently logon user. for ONLOGON.
- TODO why start menu shortcuts doesn't appear in win 10 guest?
start menu folder is created. but only one exe there.
txt file shortcuts are not added.
- DAILY trigger, why repeat every 10min?
/RI interval Specifies the repetition interval in minutes. This is
not applicable for schedule types: MINUTE, HOURLY,
Valid range: 1 - 599940 minutes.
If either /ET or /DU is specified, then it defaults to
10 minutes.
just remove /ET? /K requires /ET.
I can make use of /RI, run mbackup every 30min.
TODO what happen if last run have not finished yet?
does /RI interval count from last exit?
** 2019-11-12 how to test it? test it in a win 10 VM?
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment