' -*- vbscript -*- ' hello world ' print a simple string on stdout Wscript.echo "Hello World" ' argv ' access command line parameters (no segmentation fault accepted, nor silent exception, so some languages must explicitly check the presence of the argument) Wscript.echo Wscript.Arguments(0) ' env ' access environment variable Set s = WScript.CreateObject("WScript.Shell") Wscript.echo s.Environment("PROCESS")("HOME") ' test file exists ' return exit code error (non zero) if a file does not exist Set f = CreateObject("Scripting.FileSystemObject") if not f.FileExists("/etc/mtab") then wscript.quit(1) ' test file readable ' return exit code error (non zero) if a file is not readable On Error Resume Next Set f = CreateObject("Scripting.FileSystemObject") if f.GetFile("file2.txt") = Nothing then wscript.quit(1) ' formatting ' print integers in a simple formatted string a=1 : b=2 WScript.echo a & " + " & b & " = " & a + b ' system ' call an external program and check the return value Set s = CreateObject("WScript.Shell") Set e = s.Exec("false") If e.exitCode > 0 Then wscript.stderr.writeline "false failed" s.Exec("echo done")