How to make a pause in a script

(imported topic written by arnaud91)

Hi,

I would like to implement pauses in a script, some thing like:

action 1

action 2

wait 20 seconds

action 3

Is there a simple way to do it ?

(imported comment written by jessewk)

Hi Arnaud,

There is a pretty simple way we use regularly. You can use the ‘pause while {}’ action. Inside the {} you put a relevance expression. Our common practice is to write a time stamp to the registry (or use a client setting so it will work on non-Windows), and then set the pause while to wait for either some condition on the computer to change and/or a certain period has passed.

Here is an example from our AV deploy Task:

// Set starting time.

setting “_BESClient_PauseWhile”="{now as string}" on “{parameter “action issue date” of action}” for client

// Pause until AntiVirus is installed or 10 minutes has passed.

pause while {(not exists key “HKEY_LOCAL_MACHINE\SOFTWARE\ComputerAssociates\eTrustAntivirus” of registry) AND (now - (value of setting “_BESClient_PauseWhile” of client as string as time)) < 10*minute}

(imported comment written by arnaud91)

Hi Jesse,

Thanks, I will try it asap.

Best regards.

(imported comment written by arnaud91)

I just tested it => it works fine.

Thanks a lot for your help, Jesse.

(imported comment written by cstoneba)

What would be the command to just pause, say for 30 seconds? It’s not working for me.

pause while {(now - (value of setting “_BESClient_PauseWhile” of client as string as time)) < 30*second}

(imported comment written by jessewk)

I recommend using this syntax:

parameter “startTime”="{now}"

pause while { (your condition) AND (now-time(parameter “startTime”) < 30*second) }

continue if { not (your condition) }

Jesse

(imported comment written by BenKus)

FYI… A slightly different approach for “poor man’s sleep” in a cmd shell:

http://malektips.com/dos0017.html

// sleep 10 (change the 10 to sleep at different times
waithidden cmd.exe /C ping 127.0.0.1 -n 10 -w 1000> nul

Ben

(imported comment written by Elgin91)

Hi Jesse,

if all I need is a simple 30 second pause and no other conditional, your recommended syntax above can be simplified to:

parameter “startTime”="{now}"

pause while { (now-time(parameter “startTime”) < 30*second) }

correct ?

(imported comment written by BenKus)

Hey Elgin… Yep…

Ben

/ for 3 seconds

parameter “start” = "{now}"
pause while {now < ((parameter “start” of action) as time) + (“00:00:03” as time interval)}

/for 1 hour

parameter “start” = "{now}"
pause while {now < ((parameter “start” of action) as time) + (“01:00:00” as time interval)}

1 Like