I have a batch file that's run by TCStart.btm that I'd like to have do something different when it is run the first time a TCC session is created after system reboot than it does in later runs. Is there any way to accomplish this?
I have a batch file that's run by TCStart.btm that I'd like to have do something different when it is run the first time a TCC session is created after system reboot than it does in later runs. Is there any way to accomplish this?
You could check that something the batch file does has been done before. For example, if one of the chores is to start SHRALIAS, the batch file could check "ISAPP SHRALIAS.EXE"
You could check for the existence of (and SET /V if necessary) a flag in the volatile environment indicating that the batch file had been run. Variables in the volatile environment disappear upon logoff.
Use a zero-length file as a sentinel. Use TCSTART to check if it's older than the time since system start (see _WINTICKS) and if so, do your first-time job, then use TOUCH to change the file's time stamp. Now any further invocations of TCSTART will find the file newer than system start, so the job will not be repeated. The benefit (compared with Vince's method) that the file survives repeated logging on/off without system restart, while the volatile variable would force you to execute the task after each logout/login. OTOH that may be what you really want...
Steve, Vince's solution is exactly what I was looking for since what I wanted to know is whether this was the first time TCStart.btm has been executed since initial log on after (re-)boot (sleep and hibernate don't count). I had a bit of trouble with it because of my habit of using SetLocal/EndLocal and that both destroyed the environment variable ("/E" on the set command) and the volatile registry entry, and I don't really know how that is accomplished. However getting rid of the SetLocal/EndLocal made things work perfectly.
I had a bit of trouble with it because of my habit of using SetLocal/EndLocal and that both destroyed the environment variable ("/E" on the set command) and the volatile registry entry, and I don't really know how that is accomplished. However getting rid of the SetLocal/EndLocal made things work perfectly.
Steve, Vince's solution is exactly what I was looking for since what I wanted to know is whether this was the first time TCStart.btm has been executed since initial log on after (re-)boot (sleep and hibernate don't count).
AFAIK Vince's solution (using a volatile registry variable) is for EACH login. In other words, if you log out after the initial login, and log in again, the volatile registry variable will not exist, and you will reexecute the process you wanted to run only once after system start. Depending on your practice, the two may be equivalent. For example, on my desktop I normally log in only once, after system start, and just stay logged in for many days. Only on my laptop, which is sometimes used by others, do I normally log out without turning the power off.
HTH.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.