title: Which to choose on Windows: VBScript, JScript, Wscript
body: <p>I need to write some scripts for WinXP to support some of the analysts here at Big Financial Corp.  I need to decide which type of Windows scripting best fits my needs.</p>
  <p>My needs seem pretty simple (to me anyway)</p>
  <ol>
  <li>run on WinXP Pro SP2 (version 2002)</li>
  <li>not require my users to install anything (so PowerShell is out. Likewise Perl, Python, and other common suggestions for these types of questions on Stack Overflow)</li>
  <li>written in a non-compiled language (so users have a chance to modify them in the future)</li>
  <li>reasonably complete language features (especially date/time manipulation functions. I would like to also have modern concepts like subroutines, recursion, etc)</li>
  <li>ability to launch and control other programs (at the command line)</li>
  </ol>
  <p>From my hurried review of my options, it looks like my choices are</p>
  <ol>
  <li>VBScript</li>
  <li>WScript</li>
  <li>JScript</li>
  </ol>
  <p>I don't have time to learn or do an in-depth review of these (or whatever else a standard install of WinXP has available). I need to pick on and hack something together as quickly as possible.</p>
  <p>(Current crisis is the need to run a given application, passing several date parameters).</p>
  <p>Once the current crisis is over, there will be more requests like this.</p>
  <h2>Edit</h2>
  <p>My current skill set includes Perl, JavaScript, and Java so I'm most comfortable using something similar to these</p>
  <h2>Edit</h2>
  <p>OK. I'll try writing a WSH file in JScript. I'll let you know how it goes (and figure out accepting an answer) once things settle down around here a bit.</p>
  <h2>Edit</h2>
  <p>It all worked out in the end. Thanks for the quick responses folks. Here's what I gave my user:</p>
  <pre><code>&lt;job id=&quot;main&quot;&gt;
      &lt;script language=&quot;JScript&quot;&gt;
  // ----- Do not change anything above this line ----- //
  
  var template = &quot;c:\\path\\to\\program -##PARAM## --start ##date1## --end ##date2## --output F:\\path\\to\\whereever\\ouput_file_##date1##.mdb&quot;;
  
  // Handle dates
  // first, figure out what they should be
  dt = new Date();
  var date1 = stringFromDate(dt, 1);
  var date2 = stringFromDate(dt, 2);
  
  // then insert them into the template
  template = template.replace(new RegExp(&quot;##date1##&quot;, &quot;g&quot;), date1);
  template = template.replace(new RegExp(&quot;##date2##&quot;, &quot;g&quot;), date2);
  
  // This application needs to run twice, the only difference is a single parameter
  var params = [&quot;r&quot;, &quot;i&quot;]; // here are the params.
  
  // set up a shell object to run the command for us
  var shellObj = new ActiveXObject(&quot;WScript.Shell&quot;);
  
  // now run the program once for each of the above parameters
  for ( var index in params )
  {
      var runString = template; // set up the string we'll pass to the wondows console
      runString = runString.replace(new RegExp(&quot;##PARAM##&quot;, &quot;g&quot;), params[index]); // replace the parameter
      WScript.Echo(runString);
  
      var execObj = shellObj.Exec( runString ); 
      while( execObj.Status == 0 )
      {
          WScript.Sleep(1000); //time in milliseconds
      }
      WScript.Echo(&quot;Finished with status: &quot; + execObj.Status + &quot;\n&quot;);
  }
  
  
  // ----- supporting functions ----- //
  
  // Given a date, return a string of that date in the format yyyy-m-d
  // If given an offset, it first adjusts the date by that number of days
  function stringFromDate(dateObj, offsetDays){
      if (typeof(offsetDays) == &quot;undefined&quot;){
          offsetDays = 0;
      }
      dateObj.setDate( dateObj.getDate() + offsetDays );
  
      var s = dateObj.getYear() + &quot;-&quot;;     //Year
      s += (dateObj.getMonth() + 1) + &quot;-&quot;; //Month (zero-based)
      s += dateObj.getDate();              //Day
  
      return(s);
  }
  
  // ----- Do not change anything below this line ----- //
      &lt;/script&gt;
  &lt;/job&gt;
  </code></pre>
  <p>Clearly it could be better... but it got the job done and is easy enough for my user to understand and extend himself.</p>