I am new to TCL. I need to launch a vbs from inside a TCL file type.
Can anyone help me with that?
TIA.
The simplest solution is [exec] (set res [exec file.vbs]).
More advanced is to rewrite it in Tcl ;-).
Eckhard
Do I need to write the file name insdide quotation mark? meaning
(set res [exec "c:\\1.vbs"]).
> Do I need to write the file name insdide quotation mark? meaning
> (set res [exec "c:\\1.vbs"]).
Doesn't matter - as long as you escape white spaces with \
It is also perfectly ok to write C:/1.vs instead of C:\\1.vbs. It
decreases the number of \ in path names...
Eckhard
This is weird becuse I do have file 1.vbs at c:\
what's the reason? I use TCL 8.3.
BTW, Should I install newer TCL version due to critical bug fix in
newer TCL version?
[exec] works only with executable files. I just google'd around and
found out that .vbs files need an interpreter called "wscript.exe". So,
to make it work, you have to update the command: "set res [exec wscript
C:/1.vbs]", given wscript is in your PATH. Try it by opening a cmd and
type "wscript C:\1.bs". This works for me.
Maybe recode it really in Tcl, after all..... ;-)?
> BTW, Should I install newer TCL version due to critical bug fix in
> newer TCL version?
No, I don't think so... But 8.3 is really old. If you want to be more
up to date I recommend to install 8.4. Prebuilt binaries are available
from ActiveState (www.activestate.com, browse for ActiveTcl).
BTW 1: A very nice way to run Tcl scripts is Tclkit, which can be found
at http://www.equi4.com/. With this, no installation at all is
required.
BTW 2: the next version 8.5 is around the corner, you can even try
this...
Eckhard
You may want to try:
set res [exec {cmd.exe /c start c:/1.vbs}]
This will cause the Windows command shell interpreter to find the
appropriate Visual Basic script engine for you.
? It doesn't for me ...
... and aren't $env(COMSPEC) and auto_execok the right generalizations
of cmd.exe? I'll make that explicit: more general *and* correct even
than what Dennis wrote is
set res [eval exec [auto_execok start] c:/1.vbs]
I believe.
Yes, auto_execok is a more generalized version. However, cmd.exe should work
on any Windows NT or newer version of Windows.
I also haven't seen any Windows XP systems on which the start command
couldn't execute a VBS file.
So I was assuming people were dealing with a somewhat recent version of
Windows.
I think we're confusing each other. What exact display do
you see when you run
exec {cmd.exe /c start c:/1.vbs}
? Apart from questions about which version of Windows any
of us are running, or whether c:\1.vbs is present on a
particular host, I believe there's an issue with the
semantics of [exec].
Sorry about that. The correct command should be: (now that I've had enough
sleep)
set res [exec cmd.exe /c start c:/1.vbs]
I actually tried this on my Windows XP system and it works.