Sorry,
I got lazy on that one, firing off a reply without actually testing it :(
I believe that you can get what you are after by using the Run method insteadof
Exec. The following (tested this time!) is an example:
var WshShell = new ActiveXObject( "WScript.Shell" );
var Starting_Time = new Date();
var oExec = WshShell.Run( "c:\\windows\\system32\\notepad.exe", 1,
true );
if ( oExec.status == 1 )
{
var Ending_Time = new Date();
WScript.Echo( "Starting_Time: " + Starting_Time + "Ending_Time:
" + Ending_Time );
}
else
{
WScript.Echo( "Error returned." );
}
More detail can be found here:
http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx
Mike
--- In amibroker@xxxxxxxxxxxxxxx,
"ta" <tagroups@xxx> wrote:
>
> Thanks Mike. In the jscript code below I am getting the starting time
> correctly. The problem was with the ending time, as the script does not
wait
> for the exe to complete its run before it was giving the ending time. I
> rewrote it as follow in _vbscript_, it does the job for me . I realy don't
> know jscript or _vbscript_. This was one time thing. Again as always thanks
a
> million for all your contributions on this board.
>
>
>
> Dim WshShell, oExec, Ending_Time, Starting_Time
>
> Set WshShell = CreateObject("WScript.Shell")
>
> Starting_Time = FormatDateTime(time, 3)
>
>
>
> Set oExec = WshShell.Exec("c:\\Amibroker\\mytask.exe /f ")
>
>
>
> Do While oExec.Status = 0
>
> Ending_Time = FormatDateTime(time, 3)
>
> Loop
>
> WScript.Echo "Starting_Time = " & Starting_Time & "
Ending_Time = " &
> Ending_Time
>
>
>
>
>
> From: amibroker@xxxxxxxxxxxxxxx
[mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of Mike
> Sent: Thursday, January 07, 2010 5:34 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: OT: Jscript Help
>
>
>
>
>
> Use one of the *methods* on the Date object to get the value.
> See: http://www.tizag.com/_javascript_T/_javascript_date.php
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com> , "ta"
> <tagroups@> wrote:
> >
> > I asked a programmer to create exe file for me to manipulate AB data
> files.
> > I want to time how long it takes for it to accomplish various tasks.
So, I
> > wrote the following script to measure how long it take to run the
> mytask.exe
> > file. However, it does not work as intended. Any help or suggestions
would
> > be appreciated. TIA
> >
> >
> >
> > var WshShell = new ActiveXObject("WScript.Shell");
> >
> > var Starting_Time = new Date();
> >
> >
> >
> > var oExec = WshShell.Exec("c:\\Amibroker\\mytask.exe /f ");
> >
> >
> >
> > if( oExec.status == 0 )
> >
> > {
> >
> > var Ending_Time = new Date();
> >
> > WScript.Echo("Starting_Time: " + Starting_Time +
> > "Ending_Time: " + Ending_Time);
> >
> > }
> >
>