Vbscript delay of 5 seconds - vbscript

I have two VBScripts. ScriptA calls ScriptB using the command below
C:\Windows\System32\wscript.exe"" //Nologo //B ""C:\Program Files\ROC\ScriptB.vbs
From the ScriptA log file I can see at every run there is a delay of 5 seconds in starting ScriptB. Both scripts runs on Windows XP.
Is this a default behaviour? how can I change this?

Windows XP won't add a delay to the start of the second script. There may be a delay if the system is under extremely heavy load, but doubtful with just a vbscript.
The best way to determine where your delay is coming from is to search through scriptA and see if you can find any Sleep methods being used. Sleep takes in an argument that tells it to pause for that many milliseconds, so you would pause for 5 seconds if you had a Sleep(5000) statement somewhere in your code.
If sleep is not being called, then most likely scriptA is just finishing up some code that doesn't log out to the log file before scriptB gets kicked off. If you want to determine the exact point of the delay, start at the point in scriptA where you call scriptB and add a two log statements that will print out the time to the log file. Slowly move the first log statement upwards away from the point where scriptB is called and you will be able to determine which code is taking 5 seconds to process before scriptB is started.

Related

Azure-Pipelines - Script that requires Ctrl+C or Typing 'y' to end

I'm using Azure-Pipelines for my CI Pipeline running on windows-2019. One of my cmd scripts generates output report files and continues to run until either Ctrl+C is pressed, or 'y' is typed. How is this done? If I add another script after this one as 'y', it will never reach because the previous command will never terminate.
In the meantime, I added the "timeoutInMinutes" param to the script so it timeouts in a minute, but this still causes a task error which is not ideal.
Does anyone have any ideas on how I can end the first script once it's complete? (It takes about 5 seconds to complete the necessary task)
You can't. it is impossible to enter a user input during Azure Pipeline.
You must edit your script to not finish and wait for user input.

Making an echo line stay on screen for a certain time

As I said in the title i have a batch file with echo lines. I want them to stay each on the screen for a certain period of time. Could you give me an exemple of such?
You can do this using sleep command. For example:
SLEEP 5
This will delay the execution for 5 seconds.

GUI interaction, waiting until the window is open

Is there a bash command that waits for a window to open? Right now I'm doing something along the lines of:
open-program
sleep 100 # Wait for the program to open
send-keyboard-input
Is there a way to have "send-keyboard-input" wait until open-program finishes, eliminating the sleep 100? The time always varies, sometimes it's 90 seconds, sometimes it's 50 second.
Have you tried this?
open-program && send-keyboard-input

Getting Thread not to run until join in ruby

I am getting into ruby and have been using threads for a little while now with out fully understanding them. I notice that when adding a thread to an array and if I add a sleep() command as the first command the thread does not run until I do a join which is mostly what I want. So I have 2 questions.
1.Is that suppose to happen?
2.Is there a better way to do that other then the way I'm doing it. Here is a sample code that I have to show what I'm talking about.
job = Array.new
10.times do |n|
job << Thread.new do
sleep 0.001
puts "done #{n}"
end
end
#job.each do |t|
#t.join
#end
puts "End of script"
Output is
End of script
If I remove the comments output is
done 1
done 0
done 7
done 6
done 5
done 4
done 3
done 2
done 9
done 8
End of script
So I use this now but I don't understand why it does that. Sometimes I notice even doing something like `echo hi` instead of sleep does the trick.
Thanks in advance.
Timing of threads isn't a defined behavior. Once you put them to sleep, they will be put in a queue to be run later. You can't ever expect it to run one way or another.
Your main program doesn't take very long to run, so it is likely to happen to finish before your other threads get picked back up to run again. Really, when you think about it, 0.001 seconds is quite a long time to computer, so spinning off 10 threads in that time is likely to happen -- but even if it takes longer, there is no guarantee the thread will resume immediately after .001 seconds. Often there's really no guarantee it won't start before .001 seconds, either, but sleep calls usually don't end early.
When you add the join calls, you are introducing additional time into your main thread which allows the other threads time to run, so this behavior is expected.

Delay activity not always working in Sharepoint 2010 workflow

Currently we have a sequential workflow in sharepoint 2010 that has a delay activity.
The delay is set to five minutes. The workflow checks on the status of five tasks and depending on the results, it either delays or completes.
I have a workflow history log item set to write right before the delay and right after the delay.
Sometimes the delay does not fire, an example would be as follows:
Delay activity fires every five minutes for 3 full days on one item, then for no particular reason it fails to wake up for 17 hours...then fires and completes.
Any ideas? I have verified all of the timer services are running properly etc.
The other odd thing is that there can be 20 workflows items running and only 4 or 5 will have this issue, it seems totally random.
Also: If I make a change to the workflow item that causes the workflow to re-run, the delay activity will awaken at the next 5 minute cycle.
Update: I have found an error in my error log that occurs when the delay fails to awaken.
Workflow ID=07acf527-d5cb-41c7-a8e4-58329652dc53 attempting to run on a thread currently executing workflow ID=fe2d7670-7d3e-4e6a-b024-0cc3485aa73b. This workflow will be run at a later time.
Update: Apparently this is occurring because the workflow with the delay is being started programmatically from another workflow. This causes the second workflow to be started in the same thread. Anyone know how to specify a new thread programmatically?
Update 2: I setup some workflows to run with a 5 minute delay to see if there was any pattern to the sleep cycles. The workflows slept at 5 minute intervals for around 6 hours then the timer started to increment as follows
5 minutes
15 minutes
45 minutes
1.5 hours
3 hours
6 hours
12 hours
It looks like the delay timers are being doubled for the most part. I sure MS can figure this one out, I have tons of logs and examples.
This issue has been resolved. I had forgotten to post the resolution...
Three settings needed to be modified. Workflow Throttle, Workflow Batch, and the Hidden Workflow Timer.
You can check the current throttle setting by running the following command:
stsadm -o getproperty -pn
workflow-eventdelivery-throttle
Here is my new setting:
stsadm -o setproperty -pn
workflow-eventdelivery-throttle -pv
"45"
You can check the current batch size setting by running the following command:
stsadm -o getproperty -pn
workitem-eventdelivery-batchsize
Here is my new setting.
stsadm -o setproperty -pn
workitem-eventdelivery-batchsize -pv
"250"
You can check the current interval setting by running the following command, in which you replace the URL with a valid path to a SharePoint application:
stsadm -o getproperty -pn job-workflow
-url http://yoursiteurl
Here is my setting:
stsadm -o setproperty -pn job-workflow
-pv "Every 5 minutes between 0 and 59" -url http://yoursiteurl

Resources