melemary
Posts: 1
Joined: Mon Apr 20, 2015 9:32 pm

scheduled tasks "task scheduler"

I'm evaluating Advanced Installer for a purchase. I'm adding a program to the scheduled task and its working as expected. However, I need to add a delay on start-up. Any one is successful?
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: scheduled tasks "task scheduler"

Hello and welcome to our forums,

Unfortunately, we don't have predefined support to specify a delay for the created scheduled tasks. However, as a workaround you can create an EXE wrapper over your application, which will launch the application with a desired delay. Then, you can create the scheduled task for the EXE wrapper.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
MarcSinfo
Posts: 1
Joined: Thu May 07, 2015 1:21 pm

Re: scheduled tasks "task scheduler"

Hi,

Here are two vbscript that I use to create and remove schelued task.

Here is the code I use to Create a scheduled task:

'==========================================================================
'
'
'
' Name: Create Scheduled task
'
'==========================================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colScheduledJobs = objWMIService.ExecQuery _
("SELECT * FROM Win32_ScheduledJob")
For Each objJob in colScheduledJobs
If objJob.Command ="c:\MY EXE.exe" Then
WScript.Quit
End If
Next


RUN_REPEATEDLY =False
'DaysOfMonth = 32 Or 128
InteractWithUser =True
'
heure = Right (Now + TimeSerial (00,03,00)+ TimeSerial (-01,00,00),8) 'détermine l'écart de temps à ajouter heures, minutes, secondes ** determines the time difference to add hours, minutes, seconds
'heure = Time + TimeSerial (00,30,00) 'détermine l'écart de temps à ajouter heures, minutes, secondes ** determines the time difference to add hours, minutes, seconds
'heure = heure + TimeSerial (-01,00,00) 'ajustement heure avancé ** Daylight time adjustment
heure = Replace (heure, ":","")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create ("c:\RemoveTree.exe", "********" & heure & ".000000-300",RUN_REPEATEDLY , , ,InteractWithUser , JobID)


And here is the code to remove a scheduled task:

'==========================================================================
'
'
' NAME: Remove Scheduled task
'
'==========================================================================
'Replace "PATH TO THE EXE\MY EXE.exe" below with the appropriate info to identify the scheled task to delete

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colScheduledJobs = objWMIService.ExecQuery _
("SELECT * FROM Win32_ScheduledJob")
For Each objJob in colScheduledJobs
If objJob.Command ="PATH TO THE EXE\MY EXE.exe" Then
JobNumber = objJob.JobID
strComputer = "."
Set objService = GetObject("winmgmts:\\" & strComputer)
Set objInstance = objService.Get("Win32_ScheduledJob.JobID=" & JobNumber )
objInstance.Delete
End If
Next
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: scheduled tasks "task scheduler"

Hello and welcome to Advanced Installer forums,

Thank you for contributing to our forums. Certainly your post will be useful for future users facing with similar scenarios.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”