Thanks again
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Sent: Thursday, January 07, 2010 11:45 PM To: [email protected] Subject: [amibroker] Re: OT: Jscript Help 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 [email protected] <mailto:amibroker%40yahoogroups.com> , "ta" <tagro...@...> 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: [email protected] <mailto:amibroker%40yahoogroups.com> [mailto:[email protected] <mailto:amibroker%40yahoogroups.com> ] On Behalf > Of Mike > Sent: Thursday, January 07, 2010 5:34 PM > To: [email protected] <mailto:amibroker%40yahoogroups.com> > Subject: [amibroker] Re: OT: Jscript Help > > > > > > Use one of the *methods* on the Date object to get the value. > See: http://www.tizag.com/javascriptT/javascriptdate.php > > Mike > > --- In [email protected] <mailto:amibroker%40yahoogroups.com> <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); > > > > } > > >
