Daydream Lab
Subscribe to the Daydream Lab [RSS]

“Early Christians transformed the world by thinking different and living different, not by complaining about everybody else’s morals.”

—Alan Wilson

“‘You are destroying yourself,’ he cried. ‘You have the inclination to be alone and to dream and you are afraid of dreams. You want to be like others in town here. You hear them talk and you try to imitate them.’”

—Sherwood Anderson

“On earth we are wayfarers, always on the go. This means that we have to keep on moving forward. Therefore be always unhappy about what you are if you want to reach what you are not.”

—St. Augustine

“In the third month they began to pile up the heaps, and finished them in the seventh month.”

—2 Chronicles 31:7 (ESV)

“There would so much less laughter in the world if evil people stopped talking.”

—MadPriest

“Then I commended mirth, because a man hath no better thing under the sun, than to eat, and to drink, and to be merry…”

—Ecclesiastes 8:15

“Did they teach you how to question when you were at the school? Did the factory help you grow? were you the maker or the tool?”

—Ewan MacColl

“Happiness happens when you are not thinking about it, when you are inhabiting your body comfortably…when you feel at peace with yourself and the world. When we live overprotective, overstimulated lives we expect more all the time, we find it hard to be unself-conscious and just do what we do; we overanalyse.”

—Rowan Williams

“You can never win a war against terror as long as there are conditions in the world that make people desperate—poverty, disease, ignorance, et cetera….I think people are beginning to realize that you can’t have pockets of prosperity in one part of the world and huge deserts of poverty and deprivation and think that you can have a stable and secure world.”

—Desmond Tutu

“The distrust of wit is the beginning of tyranny.”

—Edward Abbey
Contact Me

Elsewhere in my Brain

Archive by category

Archive by date

CScript or WScript

This is just a quick note on something I had to figure out how to do at work last week: Write a VBScript that always runs in CScript.exe (that is, as a console/shell script, not using the default Windows WScript.exe, which provides GUI handling.

This Usenet thread shows how to determine whether a script is running in CScript or WScript, and even how to force a script to run in one or the other. Unfortunately, it doesn’t run the script with any arguments, and doesn’t seem to work if the script is stored in a directory with any spaces in it. This one does—just use it at the front of your script.

First, this function, which just creates a string with each script argument wrapped in quotation marks:

Private Function argumentList
	Dim strArgList, strArg
	strArgList = ""

	For iX = 0 To WScript.Arguments.Count - 1
		strArg = WScript.Arguments(iX)	
		strArgList = strArgList & """" & strArg & """ "
	Next

	argumentList = strArgList
End Function

Then run the script, with the output of argumentList, in your preferred script host.

strPreferredHost = "CSCRIPT.EXE"

'Make sure this is running as a command line script.
If UCase(Right(WScript.Fullname, Len(strPreferredHost))) <> UCase(strPreferredHost) Then
	Set wshShell = WScript.CreateObject("WScript.Shell")
	wshShell.Run  strPreferredHost & " """ & _
			WScript.ScriptFullName & """ " & argumentList(), 1, True
	WScript.Quit
End If 

Field Reports:

Commenting is closed for this article.