There is another issue: if the uninstall fails, the task may have been removed and won't be restored (since there is no rollback). Also, it may be possible that on Vista and above (due to UAC) the task creation (and removal) won't run since they are not deferred (and thus may not be elevated).
This looks like a good candidate for a WixUtil-style extension (since that exe's actions work by using the ITaskScheduler/ITaskService interfaces which can be called to perform everything representable in the commandline and provide for error-checking and everything else needed to add resiliency). -----Original Message----- From: Blair [mailto:os...@live.com] Sent: Monday, July 27, 2009 11:10 PM To: 'General discussion for Windows Installer XML toolset.' Subject: RE: [WiX-users] Creating Scheduled Tasks using Wix This will work for installations and removals, but it will break with repairs (including minor upgrades/small updates and patching). It is broken because it will remove the scheduled task during repairs. One option is to set the condition for the RemoveScheduledTask to be >REMOVE="ALL"< instead of >Installed<. (http://msdn.microsoft.com/en-us/library/aa368013(VS.85).aspx). It also has to be scheduled after InstallValidate (which it is in your example). This does mean that repair still won't re-create the task, but that may or may not be an issue for you (I don't know the specifics of the schtasks.exe tool). A more "resilient" task would be to use either feature or component installation "state" syntax, but it would be good to know if the schtasks.exe tool requires you to remove any previous entry before recreating it or not. -----Original Message----- From: Phil Sayers [mailto:p...@cds-am.net] Sent: Monday, July 27, 2009 10:18 AM To: 'General discussion for Windows Installer XML toolset.' Subject: Re: [WiX-users] Creating Scheduled Tasks using Wix I have the custom actions scheduled like this: <InstallExecuteSequence> <Custom Action="CreateScheduledTask" After="InstallFinalize">NOT Installed</Custom> <Custom Action="RemoveScheduledTask" Before="RemoveFiles">Installed</Custom> </InstallExecuteSequence> I struggle with scheduling I don't "get it", but this works for me in the scenarios I have to support. I may have missed something in the scheduling that the list regulars can point out/correct. -----Original Message----- From: MacDiarmid, James D [mailto:james.macdiar...@eds.com] Sent: Monday, July 27, 2009 1:09 PM To: General discussion for Windows Installer XML toolset. Subject: Re: [WiX-users] Creating Scheduled Tasks using Wix Hi Phil, In what part of the code did you put this? I have some other things I may need to do during the uninstall. I didn't realize you could have Custom Action Codes do this. Thanks very much! Jim -----Original Message----- From: Phil Sayers [mailto:p...@cds-am.net] Sent: Monday, July 27, 2009 12:23 PM To: 'General discussion for Windows Installer XML toolset.' Subject: Re: [WiX-users] Creating Scheduled Tasks using Wix Wouldn't be complete without the custom action to remove the task for uninstall. <CustomAction Id="RemoveScheduledTask" Return="ignore" Directory=" MyDirectory " ExeCommand=""[SystemFolder]SCHTASKS.EXE" /DELETE /TN " My Scheduled Task Name " /F" /> -----Original Message----- From: Phil Sayers [mailto:p...@cds-am.net] Sent: Monday, July 27, 2009 12:19 PM To: 'General discussion for Windows Installer XML toolset.' Subject: Re: [WiX-users] Creating Scheduled Tasks using Wix Hi Jim, I think we both found the same wix snippet to manipulate scheduled tasks. I had to shuffle it around a little, and this is what I ended up with: <CustomAction Id="CreateScheduledTask" Return="check" Directory="MyDirectory" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC DAILY /TN "My Scheduled Task Name" /ST 00:00:00 /SD 01/27/2006 /TR "\"[#FullPathToMyExe]\" type=Foo1 url=[FooURL] user=[FooUSER] password=[FooPASSWORD]" /RU "NT AUTHORITY\SYSTEM" " /> I needed the escaped quotes around the label/name you want to give to your scheduled task. If you notice the ... "\" ... before the FullPathToMyExe, I had to double-up on the quotes since I need to pass command line args (type, url, user, password) to my scheduled task, the slash between the soubled-up escaped quotes is needed to re-escape it for the schtasks.exe program. This works for me on WinXp, Vista, server2003 currently untested by me on server 2008. -----Original Message----- From: MacDiarmid, James D [mailto:james.macdiar...@eds.com] Sent: Monday, July 27, 2009 11:51 AM To: General discussion for Windows Installer XML toolset. Subject: [WiX-users] Creating Scheduled Tasks using Wix I found some code to create scheduled tasks during an install. I'm having trouble with one where I have to pass the following xml string on the command-line. XML string is "<DIRECTION>UP</DIRECTION>" Here is the code that creates the scheduled task: <CustomAction Id="CREATETASK_CC_CIS_FILE_CREATION_UPLOAD" Return="check" Directory="ScheduledTasks" ExeCommand="[SystemFolder]SCHTASKS.EXE /CREATE /SC DAILY /TN Run CC <DIRECTION>UP</DIRECTION> /ST 00:00:00 /SD 01/27/2006 /TR D:\apps\nfts\NFTS V3 Batch Processors\FireBatch\FireBatch.exe /RU [%USERDOMAIN]\[LogonUser] /RP" /> Is there a way to pass that as a string and not have votive or wix look at that string as xml? Thanks, Jim ------------------------------------------------------------------------ ---- -- _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------ ---- -- _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------ ------ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ---------------------------------------------------------------------------- -- _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ---------------------------------------------------------------------------- -- _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users