Version 17 Installer Leaves Multiple Copies of ShrAlias

Jun 2, 2008
284
1
Newton, MA
#1
I have found that after installing updates there are multiple copies of ShrAlias running (I have seen as many as three).

-- Jay
 
Jun 2, 2008
284
1
Newton, MA
#3
My TCSTART file starts ShrAlias only if it is not already running. There is a test of _shralias; ShrAlias is run only if the value is zero.

During the installation process, there is a screen that reports that ShrAlias is running and says that it will be turned off and then restored once the installation is complete. Something is going wrong in the process. Perhaps the installer is not shutting it down, but the value of _shralias is still 0.

Running the command ShrAlias cannot start a second copy; it reports that ShrAlias is already running.

I can try to watch more carefully at the next update.

-- Jay
 
Jun 2, 2008
284
1
Newton, MA
#6
What you say may be fine in principle, but it happened again!

I just updated to build 50. The screen came up advising me that "Some files that need to be updated are currently in use". I allow the installer to "Automatically close applications and attempt to restart them after setup is complete". Then I select the option to run TCMD at the end of the install.

TCMD starts up with TCC in tab 1. It shows the following output generated by TCSTART:

TCC 17.00.50 x64 Windows 7 [Version 6.1.7601]
TCC Build 50 Windows 7 Build 7601 Service Pack 1

Running C:\tcmd\ver17\TCSTART.btm

No need to load SHRALIAS. It is already running.​

When I then run TASKLIST, it shows two ShrAlias tasks running:

PID Program Window Name
--- -------------- ----------------
6796 ShrAlias ShrAliasWindow
4388 ShrAlias ShrAliasWindow


The copy with PID 4388 is using 204K of memory; PID 6796 is using 220K. Neither has used any CPU time. I don't know how to learn any more about them.

After I run SHRALIAS /U, only PID 4388 remains. To prevent any trouble, I run SHRALIAS /U again to kill the remaining one and then run SHRALIAS afresh to get it running again. After that, I have PID 7380 using 188K.

-- Jay
 
#8
Does the installer offer to restart SHRALIAS? That doesn't seem right. I wouldn't expect SHRALIAS to find any memory mapped files to guard if it wasn't started by TCC.
 
#10
As I said, it seems silly for anything but TCC to start SHRALIAS. If fact, I wouldn't expect SHRALIAS to keep running if it weren't started by TCC. Could that be the problem ... the installer restarts it and it stays running (when it shouldn't)?
 
#11
This is something that I have never seen happen with previous versions of Take Command.

I have an alias called "update" that calls "option /u". I have now added code to unload ShrAlias first.
 
#12
Well, even though I had shut down ShrAlias before updating, after updating to build 51 and launching TCMD, there were two copies of ShrAlias running. Now, I did not discover this until after opening some additional tabs, so I don't know that two copies appeared immediately.
 
#13
Well, even though I had shut down ShrAlias before updating, after updating to build 51 and launching TCMD, there were two copies of ShrAlias running. Now, I did not discover this until after opening some additional tabs, so I don't know that two copies appeared immediately.
Q: Were any there after the install but before you launched anything?
 
#14
I don't know when they appeared. Now that I have seen this even after I at least thought that I had shut down all copies of ShrAlias before updating to the new build, I will try to remember to watch very carefully at the next update. Perhaps there had been three copies before I ran ShrAlias /u in my update alias. The installer did not report that ShrAlias was running and ask me if it should shut it down. So, if there were copies running, they were not visible to the installer. This is all very bizarre.
 
May 26, 2008
495
3
#15
I haven't seen this problem and I update versions pretty frequently. The installer always prompts to shut down shralias, which I let it do. First launch of TCMD after installation restarts sharalias (tcstart.btm starts it if it's not already running). Never had an issue with multiple instances.
 
#16
Jay, how many startup (TCC) tabs do you have defined? If one tries to start SHRALIAS too soon after another does, the second one won't be able to figure out that SHRALIAS is already running. It's quite easy to start two instances of SHRALIAS if you do it quick enough.
Code:
v:\> shralias & shralias
SHRALIAS loaded
SHRALIAS loaded

v:\> tasklist | grep -i shra
  5504  ShrAlias  ShrAliasWindow
  4516  ShrAlias  ShrAliasWindow
Also, for the same reason:
Code:
v:\> shralias &  echo %_shralias
SHRALIAS loaded
0
 
#18
TCMD starts only one TCC tab, which launches ShrAlias if it is not already running. Also, I never had this problem before version 17, and my configuration has not changed in any substantive way. As I wrote earlier, I will try to remember to watch things very carefully with future updates.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,659
46
Albuquerque, NM
prospero.unm.edu
#19
Jay, how many startup (TCC) tabs do you have defined? If one tries to start SHRALIAS too soon after another does, the second one won't be able to figure out that SHRALIAS is already running. It's quite easy to start two instances of SHRALIAS if you do it quick enough.
Hmmm.... Perhaps Take Command should have an option to automatically start SHRALIAS before any tab windows?
 
May 26, 2008
495
3
#20
Maybe you could do your SHRALIAS check/load only if %_TCTABACTIVE = 1. If you are starting multiple TCC tabs on TCMD startup, only the first (active) tab would do the work.
 
May 26, 2008
495
3
#21
I'm thinking something like this for tccstart.btm. (It would need to be adjusted if you ever run TCC outside of TCMD though.)

Code:
@echo off

if %_pipe == 1 .or. %_transient == 1 quit

iff %_shralias == 0 .and. %_tctabactive == 1 then
  shralias

  history /r    "%@path[%@full[%0]]cmdhist.txt"
  dirhistory /r "%@path[%@full[%0]]dirhist.txt"
  alias /r      "%@path[%@full[%0]]aliases.txt"
  function /r   "%@path[%@full[%0]]functions.txt"

  alias desk:=%@shfolder[0]
  alias docs:=%@shfolder[5]
  alias drop:=%USERPROFILE%\Dropbox
endiff

...
...
 
#22
TCMD starts only one TCC tab, which launches ShrAlias if it is not already running. Also, I never had this problem before version 17, and my configuration has not changed in any substantive way. As I wrote earlier, I will try to remember to watch things very carefully with future updates.
It's a matter of timing, so it being one way in one version and another way in another version is not a conclusive argument that something's wrong. IIRC, the check for a running SHRALIAS is a check for the existence of a window; if the check is made too soon, the window won't exist. Jay, does your TCSTARY cause any transient or pipe instances of TCC to be started? If so, check for that in TCSTART as in Rod's example.

A better solution ... put all that loading of the lists and starting SHRALIAS in its own BTM and put it in the startup folder or run it at logon via a task. That'd avoid unnecessary stuff every time you start TCC. I have a BTM hat runs at logon and does several things that need to be done only once. Among them is:
Code:
cdd %SHRALIAS_SAVE_PATH
do c in /L history dirhistory alias function ( %c /r %c.sav )
shralias
delay 2
 
#23
My TCSTART file does check at the beginning to see if it is running in a transient or pipe, and it skips right out in those cases. I don't think this is a timing issue on my system. ShrAlias gets started only when the first tab of TCMD opens during boot up of my computer.
 
#24
I think there's only two ways to get more than one SHRALIAS running at the same time.
1. call SHRALIAS.EXE directly (which I doubt is being done)
2. call the internal SHRALIAS more than once in rapid succession
 
#25
When updating just now to build 52, I used the Task Manager to keep track of the ShrAlias copies running. I purposely left it running in TCC before I issued the command "option /u". When I got to the point in the installation process where I was asked about automatically closing it and then restarting, the installer shut it down.

Later when I clicked on the option to run Take Command now, at the point when the registration prompt came up, two copies of ShrAlias started running, as shown in the following screen capture.

upload_2014-11-13_6-23-7.png

After clicking "Continue", TCMD started and ran TCC in one tab. It showed the following:

TCC 17.00.52 x64 Windows 7 [Version 6.1.7601]
TCC Build 52 Windows 7 Build 7601 Service Pack 1

Running C:\tcmd\ver17\TCSTART.btm

No need to load SHRALIAS. It is already running.

TCSTART saw that ShrAlias was already running and did not try to load it again. Unloading it went as follows:

TCC(17.00.52): C:\Users\Jay\DOCUME~1\mydrop~1>shralias /u
SHRALIAS unloaded

TCC(17.00.52): C:\Users\Jay\DOCUME~1\mydrop~1>shralias /u
SHRALIAS unloaded

TCC(17.00.52): C:\Users\Jay\DOCUME~1\mydrop~1>shralias /u
SHRALIAS not loaded

That got rid of the two copies. Starting a second TCC tab produced the following, as expected:

TCC 17.00.52 x64 Windows 7 [Version 6.1.7601]
TCC Build 52 Windows 7 Build 7601 Service Pack 1

Running C:\tcmd\ver17\TCSTART.btm

Loading SHRALIAS
SHRALIAS loaded

set /r c:\tcmd\ver17\env.cfg
alias /r c:\tcmd\ver17\diralias.cfg
alias /r c:\tcmd\ver17\alias.cfg
function /r c:\tcmd\ver17\function.cfg
 

Attachments

#26
Good detective work, Jay. That's pretty definitive. Rex will probably figure out what's happening.

Curious ... did you notice if TWO TCCs were started (to handle the registration dialog, before TCMD)?
 
#27
Curious ... did you notice if TWO TCCs were started (to handle the registration dialog, before TCMD)?
I did not notice any TCC sessions sessions before TCMD opened and my one tab loaded. If Rex is running TCC sessions to finish the install, they should do something to avoid using the user's INI file and certainly the TCSTART script. I also don't know why more than one instance of TCC would be used (but, then again, I don't really have much of an idea about what happens during the installation).
 
#29
TCC is not used at all during installation. (Nor is TCMD, IDE, or SHRALIAS.)
So what is happening in the installer to kill and then reload ShrAlias? All I'm doing is running the installer. ShrAlias was gone before I clicked the button to start Take Command, and the two copies appeared before the registration screen came up.

Is there anything else you want me to look at during the update process (e.g., whether any TCC sessions are still running). TCMD is certainly closing, but I don't know what exactly what the installer is doing to shut it (and any TCC tabs) down.