Jump to content
jcd

Run cmd commands using tcl without opening terminal

Recommended Posts

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.

Share this post


Link to post
Share on other sites
On 2/15/2017 at 8:31 PM, tinh said:

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 ?

Share this post


Link to post
Share on other sites
On 2/24/2017 at 0:52 AM, tinh said:

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...