Welcome!

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

SignUp Now!

Test to ensure aliases are loaded

Aug
30
0
I have five btm scripts in my Startup directory to manage when certain applications, like Windows Task Manager and my file manager, start up. I use Message Boxes to put their starts on hold to allow the rest of Windows to settle down before they start. I just prefer doing it like that over having one big jumbled-up start-up.

Most of the scripts include aliases in front of the msgbox command, and they work fine 99% of the time. But, occasionally I get an error that one of the aliases doesn't exist. The error is random between which script it happens to and on which line it happens. I source a separate alias/functions file in my tcstart.btm file, and apparently the aliases haven’t "loaded" by the time the unlucky script is executed during the start-up.

I put delays in two of the scripts this was happening to regularly, but now it's also happening to another one. Is there a proper way to test for when my separate alias/functions file is loaded before a script is allowed to proceed beyond that point the test into the substantive stuff?

I don't want to have to test for the existence of every alias before I execute it, and using delays is a sorry work-around which may still not work even though I've staggered the delay times. I thought about putting a "test" alias at the end of my a/f file and just test if it exists, but I can't create a suitable test environment to test the test in.

Thanks –

Newbie
 
From: newbie
| I have five btm scripts in my Startup directory to manage when
| certain applications, like Windows Task Manager and my file manager,
| start up. I use Message Boxes to put their starts on hold to allow
| the rest of Windows to settle down before they start. I just prefer
| doing it like that over having one big jumbled-up start-up.
| ...


You did not specify:
- do you use local or global aliases
- which Startup directory: "All Users" or individual user
- how the BTM scripts are started

Here is a method that does work:
- in your individual user's startup directory put a single shortcut that starts a single instance of TCC, which uses global aliases, and is started with a unique TCSTART.BTM file
- the unique TCSTART.BTM executes the SHRALIAS, and ALIAS /R commands to load all your aliases from your alias definition file into the global alias table, after which it executes the START command to start each additional process in the desired order. When all are started, EXIT.
--
HTH, Steve
 
Thank you for your attention and time spent updating my issue.

After I got the JPSoft v11 suite last summer, I spent literally hours trying to understand the complexities of properly starting TC/TCC in reference to some of your (future) questions and instructions. Neither a former 4DOS friend nor I can figure it out, so I just write btm scripts and execute them from my file-manager, or recently from within my individual Startup directory. Your informative update raises questions I've explored before, and this update does the same. If it looks like this is morphing into a greater issue than just why I get the "no such alias" errors randomly upon reboot, then I'll be happy to just drop it and endure the error messages until I finally acquiesce to the need to check for the existence of my start-up aliases before I execute them.

Meanwhile, I offer my comments on your last update. The "errmon" and "shoiar" are the Aliases that sometimes fail to be loaded.

FROM YOUR UPDATE: "do you use local or global aliases"
ME: I don't specifically make them Global since I don't know how to do that. The Aliases are set like this:

[C:\Program Files\JPSoft\TCMD11\tcstart.btm]
(-- ENTIRE CONTENT, Left Justified --)
@echo off
"E:\@MyStuff_On_E\Apps Bats Utils\#TCSTART\ACTUAL_tcstart.btm"

[E:\@MyStuff_On_E\Apps Bats Utils\#TCSTART\ACTUAL_tcstart.btm]
(-- EXTRACTS, Left Justified] --)
@echo off
setdos /V0 /A1
unalias *
alias wina `window /pos=100,100,500,200`
alias vari `set %1=%@eval[%1+1]`
alias vard `set %1=%@eval[%1-1]`
alias dirb `dir /bhkm *%1*`
...

FROM YOUR UPDATE: "which Startup directory: "All Users" or individual user"
ME: My individual Startup directory. I only use my personal Windows XP login profile, unless I want to experiment or test something as `Guest', in which case I don't want any extraneous stuff started up.

FROM YOUR UPDATE: "how the BTM scripts are started"
ME: They are in my individual Startup directory. Some are actual files in the Startup directory that use msgbox to delay starting things like Task Manager and some are a link to a btm that starts immediately during the reboot start-up "process". An abbreviated start-up trail is:

[C:\Documents and Settings\GeorgeWho\Start Menu\Programs\Startup]
(-- THESE ARE JUST TWO EXAMPLE FILES WITH DETAILS FOLLOWING --)
"1 DK_StartupTrackerArch.btm.lnk"
"Ask ToStart TaskMngr vE.btm"
...

["DK_StartupTrackerArch.btm"]
(-- The target of a link in Startup Directory, FIRST FEW LINES ONLY --)
:: call "E:\@MyStuff_On_E\Apps Bats Utils\#TCSTART\ACTUAL_tcstart.btm"
echo Delaying 9 in "%@filename[%_BATCHNAME]"
delay 9
:: echo after delay 9
errmon
shoiar
...

["Ask ToStart TaskMngr vE.btm"]
(-- Actual file is in Startup Directory, FIRST FEW LINES ONLY --)
call "E:\@MyStuff_On_E\Apps Bats Utils\#TCSTART\ACTUAL_tcstart.btm"
errmon
shoiar
...

FROM YOUR UPDATE: "put a single shortcut that starts a single instance of TCC"
ME: My struggling understanding is that "TCC" is the Console. I've read about the Console, but I've never used it, and I have no idea how to start an instance of it.

FROM YOUR UPDATE: "which uses global aliases"
ME: From 'HELP': "Aliases can be stored in either a local or global list. The selection is made during TCC startup, using the /L or /LA START or startup options, or by the Local Aliases configuration option, or interactively with the ALIAS /G and ALIAS /L options." This reminds me of the Winston Churchill quotation describing Russia, made in a radio broadcast in October 1939: "It is a riddle, wrapped in a mystery, inside an enigma; but perhaps there is a key." Indeed, perhaps.

FROM YOUR UPDATE: "and is started with a unique TCSTART.BTM file"
ME: This confuses me because I know about -the- TCSTART.BTM file, namely "C:\Program Files\JPSoft\TCMD11\tcstart.btm". Another "unique" one would be any TCSTART.BTM in another directory (different PATH). Assuming, as I do a lot, that this is a virtual-TCSTART.BTM file, then I would write any btm-structured file in any other PATH of my choice.

FROM YOUR UPDATE: "the unique TCSTART.BTM executes the SHRALIAS, and ALIAS /R commands to load all your aliases from your alias definition file into the global alias table, after which it executes the START command to start each additional process in the desired order. When all are started, EXIT."
ME: Yes, I have read, and re-read, the Help sections "Local and Global Aliases" and "Retaining Global Aliases with SHRALIAS" Yes, they do describe WHAT to do, but only WHAT to do. Still, this does make sense if it means to write a global-alias-loading btm that then executes START for each individual btm file currently residing in, or represented by a link in, my Startup Directory. The query in my initial issue input was a primitive backdoor way of doing that. Your way is more elegant, and, unlike my way, is feasible.

I’m prepared to, and am eager to, study any resource that explains how to implement your instructions.

George
 
Try removing the "unalias *" line. If you remove aliases, then one btm file may remove the aliases just before another btm is trying to use it. Whether one btm can affect the aliases used by another depends on whether you have local or global aliases and how the btms are started.

Local or global aliases can be set via Options > Configure TCC > Local Lists. Using local aliases makes it less likely that one btm will affect the aliases used by another btm.

TCC is the program that executes your btm files and appears in a tab in Take Command. It is the program that gives you a command line where you can type commands. Try double-clicking TCC.exe.

Defining the aliases in the btm file that uses them will make problems less likely.
 
Thank you for your information.

I got an old familiar headache over your direction "via Options > Configure TCC > Local Lists" because I struggled with "Options" when I first got the Take Command v11 suite. It was déjà vu all over again with me not having a clue where to find the "Options" tab/button. I inferred from the casual nature of your direction that it must be easy. I went into the "Program Files\JPSoft\TCMD11" where I found the only other .exe with "tc" in it and double-clicked it. The Console opened up and I navigated to "Local lists" where I checked "Local Aliases". THAT's what I was unknowingly looking for in the "Help" before, and now I've found it. Whew!

I assume you read Steve's update which left me stunned. I'll poke around in the Console for awhile to see if I can figure out HOW to implement his suggestions too.

The purpose of this update is that I want to revisit a question from my initial entry. I asked if there was a way to check within a specific btm when all of the aliases are loaded when it is executed - especially during the hectic Startup period. The reason I'm interested is that I can make all of the good-intention changes like those you and Steve suggested and still not know if I've "fixed" the problem because I can't create good "Startup" conditions to replicate months of actual Startups. I thought the answer would be simple and straightforward, but I guess not.

I don't want to beat this thing to death, so if there's no further updates telling me HOW to do it, I'll invoke the Rube Goldberg methodology in my Startup directory. Besides, that'll be fun.

Regards -
Newbie
 
Just remove "unalias *". You are deleting your aliases. Your problem isn't that the aliases haven't been loaded, but that another btm is deleting them after you load them.

Windows is starting a new copy of TCC for each of your btm files. Each copy of TCC runs TCSTART.btm and then runs the btm you are trying to run. If you use global aliases, then all of the copies of TCC share the same aliases. So, when you do "unalias *", you delete all the aliases, and they disappear for all the other running btm's. If you use local aliases, then each copy of TCC will have its own set of aliases and your problem will go away (even if you keep the "unalias *" line).

If you understand what is happening, then you can fix it.

It is possible to tell if aliases have been loaded, but you shouldn't have to do that. If you really want to, then you can do something like

iff "%@execstr[alias>&>nul]" == "" then
rem No aliases loaded.
endiff

You should have shortcuts in your Start menu or on your desktop for starting TC (i.e., Take Command). The installer creates the shortcuts. Of course, you can click the tc.exe file to start it, if you wish. TC has an "Options" menu item. If you aren't running TC, then you can type "option" in a TCC window. TCC is the console, not TC.
 
We fixed it! Your Jan 23rd reply inspired me to try some more.


After I made the changes I described before (and that you reiterated on the 28th), I did a few restarts and there were no problems. Over the weekend I did 7-8 Restarts and Power Off/On reboots and there were no problems. Before, I could never get more that two in a row.


The "problem" was my naiveté and not knowing where to find the tcc.exe "Options" tab. Maybe making the Aliases Local wasn't necessary in this case, but I agree that it makes more sense in this case and in general.

Thank You for persevering in the face of a Newbie's conundrum.
 
Back
Top
[FOX] Ultimate Translator
Translate