Skip to content

$cs.Sys_Sleep

Pauses script execution for the given number of seconds. The valid range is greater than 0 and less than 14400 (under 4 hours) — values outside that range are silently ignored, meaning no sleep happens at all and no error is raised.

$cs.Sys_Sleep(int seconds)

Number of seconds to sleep. Must be greater than 0 and less than 14400.

None.

Wait for a background process to settle before continuing:

Terminal window
$cs.Job_WriteLog("Waiting 60 seconds for background process to settle")
$cs.Sys_Sleep(60)

Give a service a short grace period after restarting it before the next installer step depends on it being ready:

Terminal window
$cs.Service_Stop("MyAppService")
$cs.Service_Start("MyAppService")
$cs.Job_WriteLog("Waiting 15 seconds for MyAppService to finish initializing")
$cs.Sys_Sleep(15)

Insert a brief pause between two dependent installer steps, such as after registering a component before configuring it:

Terminal window
$cs.Job_WriteLog("Registering component, waiting briefly before configuration step")
Start-Process "regsvr32.exe" -ArgumentList "/s `"$global:Packageroot\mycomponent.dll`"" -Wait
$cs.Sys_Sleep(5)

$cs.Sys_WaitForProcess $cs.Sys_WaitForProcessToExist