ここBigFinancialCorpのアナリストをサポートするために、WinXP用のスクリプトを作成する必要があります。自分のニーズに最適なWindowsスクリプトの種類を決定するのを手伝ってください。
私のニーズはかなり単純に見えます(とにかく私には)
- WinXP Pro SP2(バージョン2002)で実行
- ユーザーに何もインストールする必要はありません(Powershellがリリースされました。同様に、Perl、Python、およびスタックオーバーフローに関するこれらのタイプの質問に対するその他の一般的な提案)
- コンパイルされていない言語で書かれている(ユーザーが将来それらを変更する機会があるように)
- 適度に完全な言語機能(特に日付/時刻操作関数。サブルーチン、再帰などの最新の概念も必要です)
- 他のプログラムを起動および制御する機能(コマンドラインで)
私のオプションの急いでのレビューから、私の選択は次のように見えます
- VBScript
- WScript
- JScript
これら(またはWinXPの標準インストールで利用可能なその他のもの)を学習したり、詳細に確認したりする時間がありません。できるだけ早く何かを選んでハックする必要があります。
(現在の危機は、いくつかの日付パラメーターを渡して、特定のアプリケーションを実行する必要があることです)。
現在の危機が終われば、このような要求がさらに増えるでしょう。
オビ=ワン・スタックオーバーフローを手伝ってください...あなたが私の唯一の希望です。
[編集]私の現在のスキルセットにはPerl、Javascript、Javaが含まれているので、これらに似たものを使用するのが最も快適です
[編集]わかりました。JScriptでWSHファイルを書いてみます。みんなありがとう...ここで少し落ち着いたら、どうなるか(そして答えを受け入れることを理解する)をお知らせします。
[編集]最終的にはすべてうまくいきました。迅速な対応に感謝します。これが私がユーザーに与えたものです
<job id="main">
<script language="JScript">
// ----- Do not change anything above this line ----- //
var template = "c:\\path\\to\\program -##PARAM## --start ##date1## --end ##date2## --output F:\\path\\to\\whereever\\ouput_file_##date1##.mdb";
// 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("##date1##", "g"), date1);
template = template.replace(new RegExp("##date2##", "g"), date2);
// This application needs to run twice, the only difference is a single parameter
var params = ["r", "i"]; // here are the params.
// set up a shell object to run the command for us
var shellObj = new ActiveXObject("WScript.Shell");
// 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("##PARAM##", "g"), 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("Finished with status: " + execObj.Status + "\n");
}
// ----- 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) == "undefined"){
offsetDays = 0;
}
dateObj.setDate( dateObj.getDate() + offsetDays );
var s = dateObj.getYear() + "-"; //Year
s += (dateObj.getMonth() + 1) + "-"; //Month (zero-based)
s += dateObj.getDate(); //Day
return(s);
}
// ----- Do not change anything below this line ----- //
</script>
</job>
明らかにそれはより良いかもしれません...しかしそれは仕事を成し遂げて、私のユーザーが彼自身を理解して拡張するのに十分簡単です。