- May
- 13,834
- 211
I'm getting a bit confused. Here's a little script, printdir.vbs.
If I run it with WSCRIPT (TCC or Start/Run)
it works, with the output of WScript.Echo going to a message box.
If I run it with CSCRIPT (TCC or Start/Run)
it also works, with the output going to the console.
All that is expected.
If I run it by name from TCC (or Start/Run)
it works with the Echo going to a message box. That is, it's run by WSCRIPT.EXE (confirmed via TaskMgr). That's odd because I have
The second oddity occurs when I run it with TCC's SCRIPT
It doesn't work. I get these, one after the other.
So I guess there are two questions. (1) Why, when I run it by name, do I get WSCRIPT instead of the associated CSCRIPT?
(2) Why can't I run it with SCRIPT?
Code:
v:\> Dim WshShell, command, tempdir, tempfile
Set WshShell = wscript.createobject("Wscript.Shell")
Set objArgs = WScript.Arguments
tempdir = WshShell.ExpandEnvironmentStrings("%temp%")
tempfile = tempdir & "\dirlist.txt"
command = "cmd /c dir /a " & Chr(34) & objArgs(0) & Chr(34) & " > " &Chr(34) & tempfile & Chr(34)
WScript.Echo command
WshShell.Run command
If I run it with WSCRIPT (TCC or Start/Run)
Code:
C:\Windows\system32\wscript.EXE u:\printdir.vbs v:\monitor.txt
If I run it with CSCRIPT (TCC or Start/Run)
Code:
C:\Windows\system32\cscript.EXE u:\printdir.vbs v:\monitor.txt
All that is expected.
If I run it by name from TCC (or Start/Run)
Code:
u:\printdir.vbs v:\monitor.txt
Code:
v:\> assoc .vbs
.vbs=VBSFile
v:\> ftype vbsfile
vbsfile="C:\Windows\System32\CScript.exe" "%1" %*
The second oddity occurs when I run it with TCC's SCRIPT
Code:
script u:\printdir.vbs v:\monitor.txt
So I guess there are two questions. (1) Why, when I run it by name, do I get WSCRIPT instead of the associated CSCRIPT?
(2) Why can't I run it with SCRIPT?