Windows2000以降はWSH(Windows Scripting Host)が標準で備わっており、特別な準備をしなくともVBScript、JScriptが使える。ファイルのコピーだとかの基本的なシェルの機能は勿論、IDispatchを備えるオブジェクトならなんでも手軽に操作することができる。


-[[WSH For Office2000:http://homepage3.nifty.com/aya_js/office2k/outlook1.htm]]

*Windows Script File [#l250db57]
XMLで強烈に柔軟性を持たせたもの。他ファイルのインクルードはおろか、複数のスクリプトエンジンの同居もできてしまう。[[「Windows スクリプト ファイル (.wsf) を使用する」:http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/script56/html/wsAdvantagesOfWs.asp]]からの抜粋だが
 <job id="IncludeExample">
    <script language="JScript" src="FSO.JS"/>
    <script language="VBScript">
       ' C ドライブの空き領域を取得します。
       s = GetFreeSpace("c:")
       WScript.Echo s
    </Script>
 </job>
などとできるわけである。凝りすぎ?
-[[Windows Scripting Host 2.0:http://homepage3.nifty.com/aya_js/wsh/wsh2.htm]]

*VBScript [#w2840068]
**利点 [#df43cb0f]
-InputBox関数が標準で使え、パラメータのインタラクティブな入力が容易
-人口と作品が多い?

**link [#l0eb2992]
-[[VBScript チュートリアル:http://tryasp.winscom.co.jp/document/vbscript/vbstutor.htm]]
-[[システム管理を自動化するVBScriptの典型的な4つのエラーと解決法:http://itpro.nikkeibp.co.jp/article/Windows/20060201/228370/?ST=win&P=1]]
-[[[VBScript Tips]:http://www.whitire.com/vbs/index.html]]

**memo [#t25ce704]
 Wscript.sleep(1000) ' 1000[ms] 待つ
 WScript.Quit ' やめる
 msgbox("hello" & "world") ' メッセージボックスを表示
 inputbox("type the param") ' パラメータ入力可能なダイアログ
 
 ' ループ
 Dim i
 For i = 1 To 10
   ' any
 Next
 
 msgbox "this is ""quoted"" string" ' 「"」のエスケープはバックスラッシュでなく連打で行う

**作品 [#pf46f0a9]
***ショートカット作成 [#kae0c0a9]
引数で指定されたフォルダへのショートカットをHOMEディレクトリに作成するスクリプト。「送る」フォルダにcreateshortcut.vbsとして配置すれば、右クリックから呼出せて便利だなあと思って作ったが、デスクトップにショートカットを作成するものが既にあり、存在意義が8割がた失われた。でもまあ学習記録として貼っておく。
 Option Explicit
 Dim objWshShell, objShortcut, strHomeDirPath, strTargetDirName, strTargetDirPath
 
 Set objWshShell = WScript.CreateObject("WScript.Shell")
 
 If 0=WScript.Arguments.Count Then 
   msgbox "no arg"
   WScript.Quit 
 Else 
   Dim objFileSystem
   Set objFileSystem = WScript.CreateObject("Scripting.FileSystemObject")
   strTargetDirPath = WScript.Arguments(0)
   If objFileSystem.FolderExists(strTargetDirPath) Then
     strTargetDirName = objFileSystem.GetBaseName(strTargetDirPath)
   Else
     msgbox "invalid arg (not a folder)"
     WScript.Quit
   End If
 End If 
 
 strHomeDirPath = objWshShell.ExpandEnvironmentStrings("%HOME%")
 
 Set objShortcut = objWshShell.CreateShortcut(strHomeDirPath & "\" & strTargetDirName & ".lnk")
 
 objShortcut.Description = strTargetDirName
 objShortcut.TargetPath = strTargetDirPath
 objShortcut.Save

*JScript [#a2f4b483]
**利点 [#w5557d2e]
-文法がC++に近いので、経験がある者にとっては記述しやすい

**link [#w20ccc6e]
-[[fooling around with JScript:http://www.imasy.org/~hir/hir/tech/js.html]]
-[[JScript - Dynamic Scripting:http://www.interq.or.jp/student/exeal/dss/ref/jscript/top.html]]
-[[WSH入門:0章 JScript概要:http://www.h6.dion.ne.jp/~binary/wsh/wsh0.htm]]