You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change "Open windows from a previous session" behavior to not automatically run .bat files without confirmation #13306
Currently if you have the setting "Open windows from a previous session" on it will re-run .bat files that were executed in a previous session. e.g.
you double-click a .bat file to run it
you close the Terminal window
you later open Terminal e.g. from Start menu
Terminal will re-run that .bat file.
I think this is very surprising and potentially destructive behavior. Users would not expect that to happen or consider the potential disasters when enabling that setting.
I initially raised this as a bug in #13151 which was closed as By Design, which is fine. This new issue is a suggestion to change the design.
Proposed technical implementation details
I think Terminal should do something else, e.g. one of these:
be more clever about what things it runs without user confirmation (e.g. perhaps it asks for user confirmation when running .bat and .cmd files on open, since they can be destructive. Or it simply never runs those types of files). I don't know enough about shells to know if this is easy/hard/impossible/annoying
give a big warning about this behavior on the setting page.
have two settings: one to persist tabs & working directories from previous sessions, one to persist potentially-destructive actions.
I don't think the setting page warning is sufficient, since many users will be blissfully unaware of all this. They might want tabs open from previous sessions, use that for months, and then just one time they use a .bat file for something. (Here, run this cleanup_files.bat but be careful not to run it with any unsaved changes). They open Terminal sometime later and BOOM the nasty .bat file has unexpectedly run. They lose their work, become sad, and end up hating Terminal forever :'(
Add an option like...
"Open windows from a previous session including defterm sessions"
vs
"Open windows from a previous session excluding defterm sessions" (this is the one that exists now)
I started working on this in https://github.com/microsoft/terminal/compare/dev/lhecker/13151-defterm-persistence but I can't figure out how to properly handle split panes where both children are DefTerm sessions. The way Pane::BuildStartupActions works isn't particularly easy to modify for ad-hoc filtering like that. I'll try to pick this up next week again and finish it with the help of others.
Activity
carlos-zamora commentedon Jul 25, 2022
Sync meeting notes:
Add an option like...
"Open windows from a previous session including defterm sessions"
vs
"Open windows from a previous session excluding defterm sessions" (this is the one that exists now)
lhecker commentedon Aug 9, 2022
I started working on this in https://github.com/microsoft/terminal/compare/dev/lhecker/13151-defterm-persistence but I can't figure out how to properly handle split panes where both children are DefTerm sessions. The way
Pane::BuildStartupActionsworks isn't particularly easy to modify for ad-hoc filtering like that. I'll try to pick this up next week again and finish it with the help of others.zadjii-msft commentedon Aug 11, 2022
Oh, we may want to cross-reference with #13596 while we're here. Maybe this needs to be two separate sets of settings: