I have looked around every forum going for this and the two solutions that are suggested are to either use Ping or use timeout. I am using the timeout, but I have the same issue with ping.
The issue I am having is that if I use the timeout command at the very beginning it works fine but if I sandwich the timeout between two calls for instance, the timeout is completely ignored.
CALL C:\Progra~1\Folder\Batchscript1.bat
timeout /t 30 /nobreak
CALL C:\Progra~1\Folder\Batchscript2.bat
The two batch scripts are both sending an email. With the set up above, this batch finishes almost instantly (should timeout for 30 seconds) and sends both emails successfully.
When I look at what is happening in the batch, I am getting the following error:
"timeout is not recognised as an internal or external command, operable program or batch file". Again this doesn't make sense too me seeing as the timeout works just fine in the below batch.
timeout /t 30 /nobreak
CALL C:\Progra~1\Folder\Batchscript2.bat
Any help would be appreciated
I assume there must be something in your call to Batchscript1.bat which is having an impact on your call to timeout.exe.
Try extending the call of timeout.exe with the fully qualified path:
"%windir%\system32\timeout.exe" /t 30 /nobreak
However, keep in mind, that you may have only treated a symptom. The cause of the issue may still affect your second script.
If you are not required to use a variable of batchscript1 in batchscript2 you should consider using setlocal and endlocal around the batchscript1 call.
Related
I have a little code I wrote that checks to see if Outlook is running, and if it is not, opens Outlook. The problem is that my work PC tends to idle around 7% usage, but spikes up to the upper 30s while the script is running. If it detects that Outlook is no longer active, CPU usage can spike up to nearly 100% while opening Outlook. This ~33% increase while the script is running could cause problems when I am working. Is there another way to accomplish the functionality of my code while using less processing power?
do{
$running = Get-Process outlook -ErrorAction SilentlyContinue
if (!$running)
{
Start-Process outlook
}
} while (1 -eq 1)
You need to add a Start-Sleep in there, to keep the script from continuously using CPU time. Otherwise it's continuously looping without rest, making sure Outlook is running. At the end of your do-block:
Start-Sleep -s 60
You can adjust the number of seconds, or even specify milliseconds instead with the -m parameter you require it.
Another way of solving this problem is running below batchfile (scheduled)
#echo off
SET outlookpath=C:\Program Files\Microsoft Office 15\root\office15\outlook.exe
for /f "usebackq" %%f in (`tasklist /FI "IMAGENAME eq outlook.exe"`) do set a=%%f
REM echo A:%a%
if not "%a%"=="outlook.exe" start "" "%outlookpath%"
If you schedule this to run every 5 minutes, than within 5 minutes after closing outlook, it will start again. If you think 5 minutes is too long, schedule it more often. 😉
While executing the below command on Freeswitch, I got the 4 times retry to 1002 while I set it to only 2 times.
originate {ignore_early_media=true,originate_continue_on_timeout=true,originate_timeout=30,originate_retries=2,originate_retry_sleep_ms=60000}user/1002 &bridge(user/1005)
Can anyone suggest me about this problem?
originate_continue_on_timeout will reset your timeout, so remove it from global variable. Probably what you want is
{ignore_early_media=true,originate_timeout=30,originate_retries=2,originate_retry_sleep_ms=60000}user/1002
&bridge({originate_continue_on_timeout=true,originate_timeout=30}user/1005)
Not tested it but should work
I tried with this below code to find out whether the webpage is opened or not, but this code is not working for me. System is just flashing only the first opened webpage URL.
surl ="http://www.google.com/"
set shapp=createobject("shell.application")
For Each owin In shapp.Windows
msgbox owin.document.location.href
if Instr(1,owin.document.location.href,surl)>0 then
msgbox "Window opened"
end if
Next
set shapp=Nothing
The error message is:
Script execution time was exceeded on script "D:\ie_open.vbs" Script execution was terminated
Given the error message "Script execution time was exceeded ...", the problem may be caused by a too small time out. See here. Use something like:
cscript //T:0 "D:\ie_open.vbs"
to test this assumption.
A default timeout value can be stored in the registry in either of the following locations:
HKCU\Software\Microsoft\Windows Script Host\Settings (per user)
HKLM\Software\Microsoft\Windows Script Host\Settings (global)
Deleting the Timeout value removes the preset timeout.
Instead of owin.document.location.href Use oWin.locationURL
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.
I am using vbscript .vbs in windows scheduler.
Sample code:
objWinHttp.Open "POST", http://bla.com/blabla.asp, false
objWinHttp.Send
CallHTTP= objWinHttp.ResponseText
strRESP= CallHTTP(strURL)
WScript.Echo "after doInstallNewSite: " & strRESP
Problem: blabla.asp is handling a task that need around 1-2 minute to complete.
It should return 'success' when the task completed.
But it return a empty result to the server vbs. (shorter than the normal time to complete the thing. I then go to check whether the task is completed, the answer is yes too.
I found this to happen when the task need longer time to complete.
Is this the weakness of vbs?
Help!!!
You can specify timeouts for the winhttp component:
objWinHttp.SetTimeouts 5000, 10000, 10000, 10000
It takes 4 parameters: ResolveTimeout, ConnectTimeout, SendTimeout, and ReceiveTimeout. All 4 are required and are expressed in milliseconds (1000 = 1 second). The defaults are:
ResolveTimeout: zero (no time out)
ConnectTimeout: 60,000 (one minute)
SendTimeout: 30,000 (30 secs.)
ReceiveTimeout: 30,000 (30 secs.)
So I suggest increasing the ReceiveTimeout
What is objHTTP specifically?
Looking at the target server's log, was the request received?
I can't find this in server log.
objWinHTTP is a standard protocol to send call and wait for response.
I did try using PHP and curl to do the whole process, but failed. Reason: PHP is part of the component in windows server. When come to global privilege and file folder moving, it is controlled by windows server. So I give up, and use vbs.
objWinHTTP is something act like curl in PHP.
sounds to me like the request to is taking too long to complete and the server is timing out. I believe the default timeout for asp scripts is 90 seconds so you may need to adjust this value in IIS or in your script so that the server will wait longer before timing out.
From http://msdn.microsoft.com/en-us/library/ms525225.aspx:
The AspScriptTimeout property
specifies (in seconds) the default
length of time that ASP pages allow a
script to run before terminating the
script and writing an event to the
Windows Event Log. ASP script can
override this value by using the
ScriptTimeout property of the ASP
built-in Session object. The
ScriptTimeout property allows your ASP
application to set a higher script
timeout value. For example, you can
use this setting to adjust the timeout
once a particular user establishes a
valid session by logging in or
ordering a product.