Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

At the Windows Command Prompt, run a Tcl script with tclsh script.tcl. If Tcl is not on your PATH, call tclsh.exe by its full path. For a script that uses Tk to create a graphical interface, use wish instead.

Run a script from its folder

Command Prompt needs a Tcl interpreter; it does not run Tcl source files on its own. If you already have Tcl installed and tclsh is available, change to the directory containing your script, then run it:

cd /d "C:UsersAliceDocumentsTcl Scripts"
tclsh hello.tcl

cd /d changes both the directory and the drive, so it also works when moving from, for example, C: to D:. The quotes keep the directory with spaces together as one path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, if hello.tcl contains:

puts "Hello from Tcl"

the command prints:

Hello from Tcl

A .tcl extension is conventional, but the important part is giving the file to the Tcl interpreter.

#1 Best Overall
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*

Run it by full path

You do not have to change directories first. Pass the script’s full path to tclsh:

tclsh "C:UsersAliceDocumentsTcl Scriptshello.tcl"

If the interpreter itself is not on PATH, quote its full path too:

"C:Program FilesTclbintclsh.exe" "D:workscriptsbuild.tcl"

The first quoted path is the interpreter; the second is the Tcl file. Using full paths is a good first troubleshooting step because it removes uncertainty about the current directory and which script or interpreter is being selected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check whether Tcl is installed and find the version

In Command Prompt, ask Windows to locate the interpreter:

where tclsh

If it prints a path, try starting Tcl:

tclsh

You should see a Tcl prompt, commonly %. At that prompt, enter:

puts [info patchlevel]
puts [info nameofexecutable]
exit

info patchlevel reports the running Tcl version, and info nameofexecutable identifies the executable. Type exit to return to Command Prompt. Do not confuse the Windows prompt, such as C:UsersAlice>, with Tcl’s interactive % prompt. Tcl’s tclsh documentation describes both running a script by filename and starting an interactive session without one.

Rank #2
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.

As of August 18, 2026, the Tcl project lists Tcl/Tk 9.0.4 as its recommended release, Tcl/Tk 8.6.18 in the 8.6 legacy sequence, and 9.1b0 as beta. Use the version your project or its extensions require rather than assuming the newest major version will work with every older script. See the project’s version guidance and distribution options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pass command-line arguments

Put arguments after the script filename:

tclsh process.tcl input.txt output.txt

Inside Tcl, the script name is available as argv0, the number of arguments as argc, and the arguments themselves as the list argv:

puts "Script name: $argv0"
puts "Argument count: $argc"
puts "Arguments: $argv"

if {$argc < 2} {
    puts stderr "Usage: tclsh process.tcl input.txt output.txt"
    exit 2
}

set inputFile  [lindex $argv 0]
set outputFile [lindex $argv 1]

puts "Input:  $inputFile"
puts "Output: $outputFile"

Quote an argument that contains spaces so it arrives as one argument:

tclsh process.tcl "C:UsersAliceMy Documentsinput file.txt"

In this example, the path is one item in argv. The behavior of quotes and escaping can depend on Windows command-line parsing and the program being invoked; Tcl documents relevant Windows caveats for quoting and executing commands.

Choose between tclsh and wish

  • Use tclsh for console programs, scripts that print text, and non-GUI work.
  • Use wish for scripts that use Tk to create windows or other graphical controls:
wish gui.tcl

If the command is not found, use the full path to wish.exe. Some installations expose version-specific names, such as tclsh90.exe, wish90.exe, or tclsh86.exe; the exact name varies by distribution and version. The Tcl tutorial describes these naming differences on Windows and other systems. A Tk script started with tclsh may fail on Tk commands; a GUI launched with wish may open a window instead of showing output in the way a console script does.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use source for interactive testing

To load a file into an already-running Tcl session, start tclsh and run source at the Tcl prompt:

Rank #3
Sale
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
  • Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
  • Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
  • Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
  • Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
  • Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable
source "C:/Users/Alice/Documents/Tcl Scripts/hello.tcl"

You can also change the Tcl interpreter’s working directory first:

cd "C:/Users/Alice/Documents/Tcl Scripts"
source hello.tcl

Forward slashes are often convenient in Tcl paths because backslashes can have special meaning inside Tcl quoted strings. source evaluates the file in the current interpreter and leaves that session open; to launch a script as a separate command-line run, use tclsh script.tcl. See the source command reference.

Troubleshooting

“’tclsh’ is not recognized”

Windows cannot find an executable named tclsh. Tcl may not be installed, its directory may not be on PATH, or the executable may have a versioned name. Check likely names:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
where tclsh
where tclsh90
where tclsh86

If you know the executable location, invoke it directly. For a temporary change limited to the current Command Prompt session, prepend the Tcl directory to PATH:

set "PATH=C:pathtotclbin;%PATH%"
tclsh script.tcl

For a permanent change, use Windows Environment Variables and avoid replacing the existing PATH. Open a new Command Prompt after changing it.

“couldn’t read file” or “no such file or directory”

The relative filename is being resolved from the current working directory, which may not be the script’s folder. Check where you are and what the file is actually called:

Rank #4
Sale
Arteck 2.4G USB Wireless Keyboard Full Size Keyboard for Computer/PC/Laptop
  • Easy Setup: Simply insert the nano USB receiver into your computer and use the keyboard instantly. Arteck 2.4G Wireless Keyboard Stainless Steel Ultra Slim Full Size Keyboard with Numeric Keypad for Computer/Desktop/PC/Laptop/Surface/Smart TV and Windows 10/8/ 7 Built in Rechargeable Battery
  • Ergonomic design: Stainless steel material gives heavy duty feeling, low-profile keys offer quiet and comfortable typing.
  • 6-Month Battery Life: Rechargeable lithium battery with an industry-high capacity lasts for 6 months with single charge (based on 2 hours non-stop use per day).
  • Ultra Thin and Light: Compact size (16.9 X 4.9 X 0.6in) and light weight (14.9oz) but provides full size keys, arrow keys, number pad, shortcuts for comfortable typing.
  • Package contents: Arteck Stainless 2.4G Wireless Keyboard, nano USB receiver, USB charging cable, welcome guide, our 24-month warranty and friendly customer service.
cd /d "C:correctdirectory"
dir
tclsh hello.tcl

Alternatively, pass the script’s full path in quotes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The wrong Tcl version runs

A machine can have more than one Tcl installation. Use where tclsh to see which executable Windows finds first, then check info nameofexecutable and info patchlevel from that interpreter. A script may behave differently when versions, installed packages, or CPU architectures differ.

“can’t find package …”

This usually means Tcl started but could not locate a dependency; it does not by itself mean the interpreter is missing. In the Tcl prompt or script, inspect package search paths with:

puts [info patchlevel]
puts $auto_path
puts $::tcl_pkgPath

Follow the project’s instructions for installing the package. A package may need to be registered on Tcl’s search path and, if it includes compiled code, match the Tcl version and Windows architecture. Avoid copying arbitrary package folders into an installation.

The script appears to do nothing or the window closes

A script can finish successfully without printing anything, and a short-lived process returns to the Windows prompt as soon as it ends. Add temporary output to see where execution reaches:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
puts "Script started"
# ...your code...
puts "Script finished"

If you need to inspect output when running from a batch file, add pause after the Tcl command in the batch file rather than adding it to the Tcl program.

Best Value
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites

Redirect output to files

Command Prompt can save standard output, standard error, or both:

tclsh script.tcl > output.txt
tclsh script.tcl 1> output.txt 2> errors.txt
tclsh script.tcl > all-output.txt 2>&1

Non-ASCII text may display or save differently depending on the Tcl build, Windows console code page, and the output file’s encoding. Do not assume every terminal and Tcl distribution uses the same encoding behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Tcl in a batch file and check its exit status

For automation, have the script return a nonzero status when it fails. For example, Tcl’s catch can report an error and exit with status 1:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
if {[catch {
    # Main program
    puts "Doing work..."
} message options]} {
    puts stderr "ERROR: $message"
    exit 1
}

exit 0

Then a Windows batch file can check the result:

@echo off
tclsh script.tcl
if errorlevel 1 (
    echo Tcl script failed
    exit /b 1
)
echo Tcl script succeeded
pause

Omit pause if the batch file should close or continue without waiting. For a quick interactive experiment, simply run tclsh, type Tcl commands, and enter exit when done. Passing a script filename is the straightforward portable way to execute a saved program; avoid relying on a tclsh -c option unless the specific Tcl distribution documents it.

Bottom line

Use tclsh script.tcl for a console script, quote paths containing spaces, and use a full interpreter path if Windows cannot find Tcl. Use wish for Tk interfaces, and check the actual Tcl version and packages when a project has compatibility requirements.

Quick Recap

SaleBestseller No. 1
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.34
Bestseller No. 2
SaleBestseller No. 3
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black
Product carbon footprint: 5.03 kg CO2e
$17.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.