Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done New environment for START and EXEC

May
13,813
211
Elsewhere, I posted this.

When I execute START /UNELEVATED d:\tc33\tcc.exe in an elevated TCC, the started process inherits the current environment. That's a small problem for me because my TCSTART.BTM changes PROMPT if TCC is elevated. The newly-started TCC is not elevated but it inherits my elevated PROMPT. There are other ways around this, but ...

I have my own RUNDOWN.EXE (more aptly named SPOOFPPID.EXE) and it suffered from the same problem. RUNDOWN.EXE uses Explorer (or a specified PID) as the parent of the new process. I worked around the problem in an obvious way (CreateEnvironmentBlock, use it CreateProcess along with the flag CREATE_UNICODE_ENVIRONMENT. I'll post code if you want.

EXEC would also benefit from this (at least optionally). I use EXEC (with no argument) often ... when I want a "fresh" instance of TCC. A new, pristine, environment would make that instance even fresher.
 
I'm not positive but it seems like, with /I, the new instance inherits TCC's startup environment, not what I'd call a "default" environment.

My /U(ser) environment specifies a green prompt. The parent, below, was started with a green prompt and TCSTART made it red. Because the start-up prompt was green and this works.

1728526671411.webp


But if TCC's start-up prompt is red (by inheritance below). It doesn't work.

1728526922471.webp
 
There are several ways to say what I think of as the "default" environment ... the environment I'd get if I started TCC from a desktop shortcut, with a double-click on tcc.exe in Explorer, from the Win+R run dialog, probably more.

START's /I gives the environment that TCC was started with. That may include any junk that was interited from whomever started TCC. And that's apparently how CMD's START works and so TCC should do it that way. So I guess I'm asking for a new feature.
 
The file approach isn't dynamic. If I wanted to emulate what Explorer would to, I'd have to update the file whenever the system or user environment changed. I often don't even know when there was such a change (installs, for example).
 
That's your goal - to get the same environment as if started from Explorer? (Which will not necessarily be the same environment as if started from, say, the Run dialog.)

And the Explorer environment will potentially change unpredictably when a third-party app does a WM_SETTINGCHANGE call.
 
That's your goal - to get the same environment as if started from Explorer? (Which will not necessarily be the same environment as if started from, say, the Run dialog.)

How might they be different? In both cases, TCC's parent is Explorer.


And the Explorer environment will potentially change unpredictably when a third-party app does a WM_SETTINGCHANGE call.

Precisely! And the new app will get the updated environment. Below, SPOOFPPID uses CreateEnvironmentBlock.

1728677698770.webp
 
I don't think it's possible to get Explorer's environment without being intrusive (and maybe setting off virus scanners). CreateEnvironmentBlock "retrieves the environment variables for the specified user". I reckon that means registry and that it will be as pristine and up-to-date as possible.

But, more to the point, I'm trying NOT to pass on TCC's current environment.
 
Back
Top