Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:26:20+00:00 2026-06-09T21:26:20+00:00

My TCL/TK application prompts the user to choose a location where to save a

  • 0

My TCL/TK application prompts the user to choose a location where to save a file.

What should the value of the -initialdir option be so that the Desktop is the default location?

I tried %userprofile%\desktop, but it’s not working.

set dir [tk_chooseDirectory -title "Where do you want to save the config file?" -initialdir %userprofile%\desktop]

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:26:21+00:00Added an answer on June 9, 2026 at 9:26 pm

    The safest way is to use twapi‘s get_shell_folder command with the argument “csidl_common_desktopdirectory” to get the path to the “all users” desktop directory, or “csidl_desktopdirectory” to get the current user’s desktop.

    If you don’t want to depend on twapi, the paths can be found in the registry, but I don’t know how reliable it is. For example:

    package require registry
    
    puts [registry get "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" "Desktop"]
    

    This returns “%USERPROFILE%\Skrivbord” on my system. You still have to expand the USERPROFILE variable (and any other variables). That’s best done with twapi::expand_environment_strings, but since you’re not using twapi, try regsub:ing %USERPROFILE% with $env(HOME) instead.

    Or if you don’t care about people with non-english Windows, just use “~/Desktop”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small shell application that embeds Tcl to execute some set of
My Tcl application should read and store a lot of configurations parameters. I'd like
I have a Tcl code that is being sourced from a C application using:
I use TCL 8.4 and for that version I need to add a new
I have a Tcl/Tk app that generates many forms and would like to be
I want to use an embed an sqlite database into an existing tcl application
I am trying to freeze an application that involves the use of the shelve
I'm working on a simple TCL script that makes a few Tk dialogs appear
In Tcl/Tk, the source of file /usr/bin/wan27 #! /usr/bin/wish -f set w .main toplevel
I've never used Tcl previously, however, I need to modify a certain file for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.