Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you run Windows commands or .cmd files in Tcl/Tk?

Status
Not open for further replies.

graemephillips

Programmer
Mar 8, 2004
8
GB
To cut a long story short, does anyone know the exact syntax one should use when using Tcl/Tk to run Windows commands i.e. the content of a .cmd file? I know how to do this using applications, for which a shortcut exists, but since I don't know of any application as such for .cmd files that is linked to by a shortcut, I don't know how this can be done.




Here is my earlier posting that no-one bothered to reply to:-

{
I have found that if I type ''exec "C:/Documents and Settings/grphilli/Desktop/wish.exe" a:/Programm.tcl'' for instance, I can run a file with Tcl/Tk. However, the problem is that I want to do this with a .cmd file.

Can one run a .cmd file in this way? If so, what do I have to type between "exec" and the filename or rather, which application does one have to use to run a .cmd file using this syntax?

Also, is there any other way to start up a Windows .cmd file from Tcl/Tk?

Given that I am fairly new to programming, please tell me what the necessary syntax is if you answer, as just saying that this is something that can be done with the exec command is of little help. Thanks.
}
 
P.S. could someone please tell me the exact syntax, rather than just saying something along the lines of that it can be done using the "exec" command.
 
Code:
  exec cmd start /c d:/temp/test.cmd
  exec cmd "" /c d:/temp/test.cmd
On my Win2k box the two commands are equivalent.
I think it would be the same on WinXP (that is Win2k based).

If "test.cmd" is a link (that's the real file name is test.cmd.lnk) I get an error.

If you omit start or "" Tcl will translate /c into \c thinking that the first arg of cmd is a file path. And the result will not be what you intended.

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top