Changing Scripting Host from WScript to CScript for Drag&Drop Operations

Hello everyone,

today I've run into a strange problem using the Windows Scripting Host. I've written a script that generates longer output texts and thus wanted it to run using the CScript interpreter (message boxes werent really handy for the output). So I've changed the Interpreter using the command:

"cscript.exe //H:cscript //s"

Though the changes worked on first sight, vbs files are being run by CScript now if I double click them, and all script file extensions are associated with CScript, scripts are still being run by WScript in case they are started by a drag and drop action instead of a doubleclick. I didn't find any "proper" way to change this behaviour so I went with a practical solution renaming the original WScript.exe and replacing it with a copy of CScript. Now vbs Scripts started by a drag&drop operation are (of course) bing started  correcly by CScript too.

Though I think such a dirty hack shouldn't be necessary. Does anyone know a proper way to fix this issue?

June 30th, 2013 6:10pm

Don't use //S

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2013 6:13pm

Hello jrv,

unluckily omitting the parameter /s doesn't change anything about Scripts launched by a Drag&Drop operation being started by WScript (tried that before and just tried it again). Actually /s will only save the options for the current user so I don't really see why that should make a difference as long as I'm logged on with the same user.

BTW I forgot to mention I'm using Win 7 Pro x64.

vbs Files seem to be interpreted by WScript if you start them by drag and drop no matter what.

June 30th, 2013 6:23pm

Drag-and-drop is not handled in the same way as double-click. AFAICT (admittedly, I didn't look very far), there is no way to change this behavior.

Bill

Free Windows Admin Tool Kit Click here and download it now
June 30th, 2013 8:33pm

Okay I just figured it out myself,

you can change the behaviour by tinkering with the registry:

Go to the key:

'HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command'

and change the command from

'"%SystemRoot%\System32\WScript.exe" "%1" %*' to  '"%SystemRoot%\System32\CScript.exe" "%1" %*'

and there you go. It seems only the 

'HKEY_CLASSES_ROOT\VBSFile\Shell\Open2\Command'

is affected by changing the default scripting host on the console using 'cscript.exe //H:cscript', which IMHO is inconsistent enough to be considered a bug.

Cheers MrN

June 30th, 2013 8:58pm

Good - I was going to suggest that but had to go out.  Glad you found it.
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2013 11:21pm

Good detective work - glad you found it, too. Marking answer.

Bill

July 1st, 2013 2:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics