🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Run cmd commands using tcl without opening terminal

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

Is it possible to run a cmd command such as 'dir' using exec or another method in tcl and store the output of that command in a string without opening up the actual cmd terminal ?

 

Thank you.

Find more posts tagged with

Sort by:
1 - 4 of 41
    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi,

    did you try:  exec cmd /C dir    

    ?

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi,

    did you try:  exec cmd /C dir    

    ?


    @tinh : Yes, i did try it. Although it seems to work for some commands, it does not work for all. For example, if the command is 'dir' it does return the output without opening a terminal and stores it into result when I use,

     set result [exec cmd /c dir]

    However, when I use 

     set result [exec cmd /c ipconfig]

    it does not return the output to my variable and instead opens up a new cmd terminal window and runs the ipconfig command in it, and closes it once the command has run, which is exactly what I want to avoid.

     

    How could I get around this issue ?

    User: "tinh"
    Altair Community Member
    Updated by tinh

    Hi,

    ipconfig is an external command (an .exe file) so you should do:

    set result [exec ipconfig.exe]

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Hi,

    ipconfig is an external command (an .exe file) so you should do:

    set result [exec ipconfig.exe]

    Hi,

    This worked perfectly for me. Thank you.