I am trying to schedule a task through wix custom action.After installing the installer the installer is adding the task in the scheduler tasks.But the task is not running at the scheduled time.Please give any solution.
What should I need to give in Directory attribute.
The code that I am using is :
<Fragment>
<CustomAction Id="CreateScheduledTask"
Return="check"
Impersonate="no"
Execute="deferred"
Directory="TARGETDIR"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /CREATE /SC ONSTART /TN "LaunchMyApp " /TR "[INSTALLDIR]AppDesktopFiles\AppLaunch.exe" /RU "NT AUTHORITY\SYSTEM" /RP /F" >
</CustomAction>
<CustomAction
Id="RemoveScheduledTask"
Return="ignore"
Directory="ProgramFilesFolder"
ExeCommand= ""[SystemFolder]SCHTASKS.EXE" /DELETE /TN LaunchMyApp /F" >
</CustomAction>
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask" After="InstallFiles">NOT Installed</Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">Installed</Custom>
</InstallExecuteSequence>
</Fragment>
If the task is created ok and you see it in the list, it doesn't seem like it's a WiX issue. The task should run at reboot. Can you isolate the specific problem to:
The task doesn't start at all.
The task starts but it doesn't launch your app.
Anyway, I don't believe your app will launch given that specification because there is no desktop folder when the system starts because nobody has logged on, and the system account is an internal account that does not have a desktop folder.
Related
I'm trying to add a custom action that will delete files from the installation folder using the following code:
<CustomAction Id="InstallService" Return="check" Impersonate="no" Execute="deferred" Directory="INSTALLFOLDER" ExeCommand='cmd.exe /C del /s /q "[INSTALLFOLDER]"'/>
<InstallExecuteSequence>
<Custom Action="InstallService" Before ="InstallFiles">NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>
This works on some computers but fails on others showing a message
A program required for install to complete could not be run.
And in the installation logs I see
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor
Any idea why this might happen or how to make it work?
I want to create a WiX package for a task scheduler. I am able to create the task while I install the package and during the uninstall from control panel am able to remove it successfully. But, when I try to install the upgraded version It gives an alert saying:
WARNING: Are you sure you want to remove the task "taskNew" (Y/N)?
Here am using the below Major upgrade statement for upgrading the msi, where the previous version will be first un installed and then the updated version will be installed.
I want this package to be installed in nightly build as per Continuous deployment. As there should not be any manual intervention, I want this to be Y for all the times. Can anyone please help on this
The commands am using for installing task scheduler:
<CustomAction Id="CreateScheduleTask"
Return="check"
Execute="deferred"
Impersonate="no"
Directory="INSTALLFOLDER"
ExeCommand="" [SystemFolder]SCHTASKS.EXE" /CREATE /TN "taskNew" /TR "[INSTALLFOLDER]installerAbc.exe" /SC DAILY /ST 12:30" />
Command used for un-installing task :
<CustomAction Id="RemoveScheduleTask"
Return="ignore"
Execute="deferred"
Directory="INSTALLFOLDER"
Impersonate="no"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /DELETE /TN "taskNew"" />
I have resolved it by updating the command itself.. By adding /f flag as below makes it to delete the task forcefully.
ExeCommand = ""[SystemFolder]SCHTASKS.EXE" /DELETE /TN "taskNew" /f;"
This question seems to have been answered ad nauseam on this web site but I cannot get Wix to run an exe with Administrator rights (Windows 8.1 64-bit).
The installer I develop copies the prop.exe utility (http://prop.codeplex.com/) to a folder under Program Files (appfolder) as well as a file (my_file.propdesc) which needs to be registered/unregistered by prop.exe like:
prop schema register my_file.propdesc (at the end of installation)
prop schema unregister my_file (at the beginning of uninstallation)
These two command lines need to be run with Administrator privileges. Because these should also be run without a command prompt, I've used CAQuietExec with another CustomAction preparing the argument for CAQuietExec (prop.exe is 32-bit so it's CAQuietExec instead of CAQuietExec64 if I am not mistaken).
<CustomAction Id='PropReg_Prep' Property='PropReg' Value='"[appfolder]prop.exe" schema register "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id='PropUnReg_Prep' Property='PropUnReg' Value='"[appfolder]prop.exe" schema unregister "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id="PropReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
<CustomAction Id="PropUnReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
The custom actions are executed as per:
<InstallExecuteSequence>
<Custom Action="PropReg_Prep" After="CostFinalize" >NOT Installed</Custom>
<Custom Action="PropUnReg_Prep" After="CostFinalize" >Installed</Custom>
<Custom Action="PropUnReg" After="InstallInitialize" >Installed</Custom>
<Custom Action="PropReg" After="InstallFiles" >NOT Installed</Custom>
</InstallExecuteSequence>
I cannot get prop to register/unregister my_file.propdesc. Could someone help?
You are scheduling the actions as Execute='immediate' this runs as the user that executes the installer.
Switch to using Execute='deferred' this will run as the system account. Assuming that the prop.exe doesn't require a full profile to run this should work.
When you're not impersonating you're running with the system account, that's got admin privileges but if you are expecting it to be a user account then there might be issues.
The thing that looks weird to me is that [appfolder]prop.exe for a number of reasons. It doesn't look like a proper application folder, so make sure it's correct. It also needs to be in uppercase, making it a public property, and you should mark it Secure="yes" in the property element. The issue is that it may not get properly transferred from your immediate CA into the execute sequence where it's used.
p.s. Do the install creating a verbose log so you can see how those directory vales are actually being resolved at run time.
I have a WiX setup which has
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
If an error during the upgrade occurs, the setup rolls back and restores the previously installed version.
However, a scheduled task created via a custom action is lost and never restored.
The custom actions I'm using for creation/removal/rollback of the task are:
<!-- task scheduling -->
<CustomAction Id="CreateScheduledTask" Return="check" Directory="SystemFolder"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Create /RU "[TASK_DOMAIN]\[TASK_USERNAME]" /RP [TASK_PASSWORD] /SC DAILY /TN "Maintenance" /TR "[\\]"[SERVICELOCATION]Maintenance.exe[\\]"" /ST [TASK_TIME]"
Execute= "deferred"/>
<!-- rollback in case something went wrong -->
<CustomAction Id="CreateScheduledTask_Rollback" Execute="rollback" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" />
<!-- removal of task -->
<CustomAction Id="RemoveScheduledTask" Return="ignore" Directory="SystemFolder" ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Delete /TN "Maintenance" /F" Execute= "immediate"/>
which are queued as
<InstallExecuteSequence>
<Custom Action="CreateScheduledTask_Rollback" Before="CreateScheduledTask"></Custom>
<Custom Action="CreateScheduledTask" Before="InstallFinalize"></Custom>
<Custom Action="RemoveScheduledTask" Before="RemoveFiles">
<![CDATA[(REMOVE="ALL")]]>
</Custom>
</InstallExecuteSequence>
The CreateScheduledTask-action had a condition of NOT Installed which I removed for testing purposes.
Can anyone tell me, what I'd need to do, in order to have the task re-created when the upgrade setup rolls back?
P.S.: I do not have access to the domain, username or password the task was originally created with.
You need another rollback custom action for RemoveScheduledTask that does essentially what is in CreateScheduledTask. For example:
<CustomAction Id="RemoveScheduledTask_Rollback" Return="ignore" Directory="SystemFolder"
ExeCommand=""[SystemFolder]SCHTASKS.EXE" /Create /RU "[TASK_DOMAIN]\[TASK_USERNAME]" /RP [TASK_PASSWORD] /SC DAILY /TN "Maintenance" /TR "[\\]"[SERVICELOCATION]Maintenance.exe[\\]"" /ST [TASK_TIME]"
Execute="rollback" />
<InstallExecuteSequence>
<Custom Action="RemoveScheduledTask_Rollback" Before="RemoveScheduledTask"">
REMOVE="ALL"
</Custom>
</InstallExecuteSequence>
You will need access to the domain, username and password to create the task the same way it was originally. You can use the Remember Property Pattern to have the properties available during uninstall, although you'll want to add another couple actions to encrypt/decrypt the password before storing it probably.
I've googled around and found some topics like
http://wix.sourceforge.net/manual-wix3/run_program_after_install.htm
and
Launch application after installation complete, with UAC turned on
but, i don't use any ui. Just simple installation!
So far
<CustomAction Id="LaunchApp" Directory="INSTALLDIR" ExeCommand="[SystemFolder]cmd.exe /C MyExe.exe" />
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action="LaunchApp" After="InstallFinalize" />
</InstallExecuteSequence>
but when i start the installer, a window pops up: "Please wait while Windows configures MyProgram". and on top of it comes cmd.exe just with a blinking cursor, when i close cmd i get message :"There is a problem with this Windows Installer package. A program required for this install to complete could not be run." Though program remains opened.
How can i do that properly (without any UI)?
Thanks in advance!
What happens if you use
ExeCommand="[SystemFolder]cmd.exe /C start MyExe.exe"
Set Return to asyncNoWait for your custom action. This way the custom action runs and the installer doesn't wait for it or check its return code.
I had the problem that it also tried to run at uninstallation.. This way it runs only on installation, reparation and updating (changing)
<CustomAction Id="LaunchApp" Directory="INSTALLFOLDER" ExeCommand="[SystemFolder]cmd.exe /C start MyFile.exe" />
<InstallExecuteSequence>
<Custom Action="LaunchApp" After="InstallFinalize">NOT REMOVE</Custom>
</InstallExecuteSequence>
Information about NOT REMOVE could be found here: https://stackoverflow.com/a/17608049/9758687