This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Import a scheduled task by using Custom Action
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 13, 2014
02:23 PM
Import a scheduled task by using Custom Action
Hello,
From within my custom action of my Basic MSI project I try to import a scheduled task from a XML file by using the "schtasks.exe" command.
When I try to do this with a custom action of type "EXE" I constantly get a 1721 or a 1722 error.
When I try to do this with a custom action of type "VBSCRIPT" no errors occur, but the scheduled task is not created.
When I use the command in a command shell that is run as Administrator also: the scheduled task is created.
The properties that I use, DOMAIN, USERNAME, PASSWORD and INSTALLDIR, are filled correctly with their values.
I am installing on a Windows Server 2008 R2 64 bit machine.
The command that I execute has this form:
schtasks.exe /Create /TN " " /RU [DOMAIN]\[USERNAME] /RP [PASSWORD] /XML "[INSTALLDIR]"
The reason why I don't use the InstallShield functionality to create a scheduled task is that it has no options to repeat a task for a certain amount of minutes. Furthermore I need to define multiple actions in one scheduled task.
I think it has something to do with too few privileges to create the task from within InstallShield, despite the setup is executed as Administrator.
Any help is greatly appreciated!
Regards,
Chris.
From within my custom action of my Basic MSI project I try to import a scheduled task from a XML file by using the "schtasks.exe" command.
When I try to do this with a custom action of type "EXE" I constantly get a 1721 or a 1722 error.
When I try to do this with a custom action of type "VBSCRIPT" no errors occur, but the scheduled task is not created.
When I use the command in a command shell that is run as Administrator also: the scheduled task is created.
The properties that I use, DOMAIN, USERNAME, PASSWORD and INSTALLDIR, are filled correctly with their values.
I am installing on a Windows Server 2008 R2 64 bit machine.
The command that I execute has this form:
schtasks.exe /Create /TN "
The reason why I don't use the InstallShield functionality to create a scheduled task is that it has no options to repeat a task for a certain amount of minutes. Furthermore I need to define multiple actions in one scheduled task.
I think it has something to do with too few privileges to create the task from within InstallShield, despite the setup is executed as Administrator.
Any help is greatly appreciated!
Regards,
Chris.
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 13, 2014
05:32 PM
Is the path to schtasks.exe specified correctly? I would also make sure that the task configuration XML file is installed before your custom action is executed if the file is installed within the same installation.
Hope that helps.
Hope that helps.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 14, 2014
01:23 AM
hidenori wrote:
Is the path to schtasks.exe specified correctly? I would also make sure that the task configuration XML file is installed before your custom action is executed if the file is installed within the same installation.
Hope that helps.
Hi,
Thanks for your answer. schtasks.exe is part of the Windows PATH environment variable so than it can be executed without the full path specified? But I also tried to set the working directory to System and System64.
The task configuration XML file is part of the installation and the custom action is executed after it is installed and modified by a previous custom action.
So my installation sequence regarding the scheduled task file is like this:
1.) ExecuteAction
2.) WriteConfig (custom VBSCRIPT): preset the application configuration files.
3.) CreateScheduledTask (custom VBSCRIPT): modifies the XML scheduled task file by inserting the INSTALLDIR, DOMAIN and USERNAME values.
4.) Import scheduled task (EXE): this one is failing, when I try to embed it in step three it generates no error but does not create te task.
Regards,
Chris.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 07, 2014
06:24 AM
Ok, I finally solved it by changing the "in-script execution" to "deferred execution in system context" so that the task will be created with administrator privileges.
The only problem I had after that is that the INSTALLDIR property was not available anymore in that context. I solved that by using a SetProperty that will copy the installdir value to the CustomActionData property. One of the few properties that is available when deferred execution is chosen.
The only problem I had after that is that the INSTALLDIR property was not available anymore in that context. I solved that by using a SetProperty that will copy the installdir value to the CustomActionData property. One of the few properties that is available when deferred execution is chosen.