![]() |
Need help with basic JavaScript
Hello,
I'm using TestComplete 9 to minimize user testing for new software releases. One of it's features is TestExecute, which runs your tests. I can have it open and run a test from the Command Prompt by writing one line of code. I've never used JavaScript (or any scripting language), but I would like to write a basic script that would open the command prompt, enter the line of code, hit enter, and then close the Command Prompt. My plan is to place the script file in Windows Scheduler and have it run every 15 minutes. I don't know where to begin, though. I'm not sure where to write it or how to write it. Any help or useful links to where I can learn? Thanks. |
I don't think you can do that. JS doesn't interact with the OS, just the browser. Security issue, and all that.
You can try VB, or Task Scheduler. |
Sorry, Wolfshade, you are wrong.
On Windows, you can execute a ".js" file from the command line. Example: Code:
cscript anyname.jsCode:
cscript updateSchedule.js "1/14/2013"You can also simply double click on a a ".js" file and have it automatically executed by the "cscript.exe" (which is part of the Windows Script Host -- WSH -- system). And, finally, yes you can use the JS code to in turn invoke other executables, using the WshShell ActiveXObject. Having said all the above, it seems likely that indeed Titanium could do this via JS (and, yes, you can use the Task Scheduler to invoke cscript and JS, of course--I do it all the time). But why? You could just as easily invoke TestExecute directly from the Task Scheduler. Unless the aim is to (for example only) randomly choose a different thing for TestExecute to do every 15 minutes, I don't see the need for JS to get involved here. |
TestExecute works differently than other programs. It knows what to open up by using the Command Prompt's input.
Any help or links I could use to figure out how to write a basic JS script to do something like this? |
I say again: Unless you will pass *DIFFERENT* parameters to TestExecute each time, you do *NOT* need JavaScript to get involved.
You *CAN* just specify the command line arguments via the Task Scheduler. Did you not know that? And even if you couldn't, you could instead create a ".bat" file that contained something like Code:
TestExecute zambonis 337 Z$4You need to explain why you think you need JS to get involved here. |
Here's the link to WSH:
http://msdn.microsoft.com/en-us/libr...(v=vs.84).aspx And you can see the link to JS there, as well: http://msdn.microsoft.com/en-us/libr...(v=vs.84).aspx |
Quote:
|
Quote:
It's trivial to schedule a JS script with the Windows Task Scheduler in this way. On two different sites that I manage, we use exactly this to perform various database cleanup and setup tasks. Some tasks run once a day, at night. Others run once an hour during the day. And all are more complex than I would care to try to do using a stored procedure, since they involve multiple steps that depend on each other. It is *SO* much easier to use a scripting language for this than it would be to do any other way. It's really no different than using CRON and a shell script on Linux. Which I have done many times before, also. But the Windows command language is just nowhere near as rich as, say, C-shell on Linux. So we need something more powerful, and JScript fills the bill very nicely. It's even easier to understand then some of the arcane structures needed in shell scripts. |
Sorry for the late response, but thank you OldPedant for your help. I honestly was not sure what I was looking for, so apologies for my ignorance on JS. And I didn't know that I could just pass the command line arguments into Task Scheduler. I've got it all set now, thanks again.
|
| All times are GMT +1. The time now is 03:19 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.